Program to check whether a given(lowecase or uppercase)character is vowel or consonant[ if else statement]
#include <stdio.h>
void main()
{
char c;
int lowercase, uppercase;
printf("Enter an alphabet: ");
scanf("%c", &c);
//if variable c is lowercase
lowercase = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); //Single quotes denote a single character .if we dont use single quotes it read as variable (indeed undefined variable )
// if variable c is uppercase
uppercase = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
// evaluates if c is either lowercase or uppercase
if (lowercase || uppercase)
printf("%c is a vowel.", c);
else
printf("%c is a consonant.", c);
}
ALSO SEE:[switch statement]
https://cprogramming00.blogspot.com/2020/01/program-to-check-whether-givenlowecase_16.html
0 comments:
Post a Comment