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


SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment