Why is the given C++ program is not working?
#include<>
using namespace std;

int main()
{
char ch;
cout<<"Enter any letter: ";
cin>>"ch";

if(ch='a' || ch='e' || ch='i' || ch='o' || ch='u'|| ch='A' || ch='E' || ch='I' || ch='O' || ch='U')
cout<<"Vowel";

else
cout<<"Consonant";
return 0;
}

Respuesta :

Answer:

Please find the edited program below:

#include<iostream>

#include <stdio.h>

using namespace::std;

int main()

{

char ch;

cout<<"Enter any letter: ";

ch=getchar();

if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'|| ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')

cout<<"Vowel";

else

cout<<"Consonant";

return 0;

}

Explanation:

We cannot input char type using cin, we need to use getchar, and it is under header file stdio.h. Also, for comparing we need to use == and not =. And corrrect way of including std is using namespace::std;