Learn C with example
Input a character and check it vowel
or not
In this example we will learn how we can find a
character is vowel or consonant.
In this example we first include two required headers
include<stdio.h> and include<conio.h>.These
are included to use methods( also call functions ) defined into these header
files.
Here we are using five methods main() method ,clrscr()
method ,printf() method,scanf method and getch() method.
In this we are using if-else to check vowel or
consonant .First enter a alphabet then compare it with five vowels(a,e,i,o,u) if
it is true then print vowel else print consonant. Here we are using OR (||)
operator to check multiple conditions at a time in if.
/* Input a character and check it vowel or not */
#include<stdio.h>
#include<stdio.h>
void main()
{
char ch;
clrscr();
printf("Enter a alphabet \t:");
scanf("%c",&ch);
if(ch=='a'||ch=='A'||ch=='e'||ch=='E'
||ch=='i'||ch==
'I'||ch=='o'||ch=='O'||ch=='u'||ch=='U')
printf("\n\nIt is a vowel");
else
printf("\n\nIt is a consonant");
getch();
}
|
Output Of Example
Enter a alphabet :a
It is a vowel |
C Aptitude Questions
C Interview Questions And Answers
C Objective Interview Questions And Answers(10)
C Subjective Interview Questions And Answers(100)
C syntax, semantics and simple programming questions(61)
C Interview Questions And Answers( Objective and Subjective)