C++ Program to Input Character and Display Vowel or Not

Write a program that prints the ASCII code of the input character (both upper case and lower case) and displays whether the character is vowel or not. e.g. if ‘A’ is inputted then the output should be 65 and should display ‘vowel’.

Write a program that prints the ASCII code of the input character (both upper case and lower case) and displays whether the character is vowel or not. e.g. if ‘A’ is inputted then the output should be 65 and should display ‘vowel’.

Source Code:
#include<iostream.h>
#include<conio.h>
void main()
{
    int num;
    char ascii;
    cout<<"Enter character:";
    cin>>ascii;
    cout<<"it ascii value is:"<<(int)ascii<<endl;
    if(ascii=='a'||ascii=='e'||ascii=='i'||ascii=='o'||ascii=='u'||ascii=='A'||
    ascii=='E'||ascii=='I'||ascii=='O'||ascii=='U')
    cout<<"It is vowel";
    else
      cout<<"Not Vowel";
    getch();
}
Output:
Enter character: a
It ascii value is: 97
It is vowel

You May Also Like...

Socialize with Us