Write a C C++ program to check vowel or consonant

 

Flowchart

Find Vowel or Consonant flowchart

 

Coding in C

#include<stdio.h>
int main()
{
char letter;
printf(“Enter a letter: “);
scanf(“%c”,&letter);
switch(letter)
{
case ‘a’:
case ‘A’:
case ‘e’:
case ‘E’:
case ‘i’:
case ‘I’:
case ‘o’:
case ‘O’:
case ‘u’:
case ‘U’:
printf(“Vowel”);
break;
default:
printf(“Consonant”);
}
return 0;
}

 

Coding in C++

#include<iostream>
using namespace std;
int main()
{
char letter;
cout<<“Enter a letter: “;
cin>>letter;
switch(letter)
{
case ‘a’:
case ‘A’:
case ‘e’:
case ‘E’:
case ‘i’:
case ‘I’:
case ‘o’:
case ‘O’:
case ‘u’:
case ‘U’:
cout<<“Vowel”;
break;
default:
cout<<“Consonant”;
}
return 0;
}

 

Output

Find Vowel or Consonant output

 

Published by

admin

I am a computer teacher, programmer and web developer