Program to enter a character and tell its type vowel or consonant in C

Logic:

  • Enter character ch
  • A character is vowel only if it is any one of the characters a, e, i, o, u, A, E, I, O, U
  • Otherwise It is a consonant

Algorithm

  1. Enter charcater ch
  2. switch (ch)
  3. {
  4. case ‘a’ :
  5. case ‘A’ :
  6. case ‘e’ :
  7. case ‘E’ :
  8. case ‘i’ :
  9. case ‘I’ :
  10. case ‘o’ :
  11. case ‘O’ :
  12. case ‘u’ :
  13. case ‘U’ : printf(“It is a vowel”);
  14. break ;
  15. default : printf(“It is a consonant”);
  16. }

Program

#include <stdio.h>
int main()
{   
    printf("***************************************************************");
    printf("\n***************************************************************");
    printf("\n**WAP to enter a character & tell its type vowel or consonant**");
    printf("\n**                        Created by Sheetal Garg            **");
    printf("\n**                          Assistant Professor              **");
    printf("\n**                          Phone No:9467863365              **");
    printf("\n***************************************************************");
    printf("\n***************************************************************\n");
    char ch;
    printf("enter a character\n");
    scanf("%c",&ch);
    switch (ch)
    {
        case 'a' : 
        case 'A' : 
        case 'e' : 
        case 'E' : 
        case 'i' : 
        case 'I' : 
        case 'o' : 
        case 'O' : 
        case 'u' : 
        case 'U' : printf(" It is a vowel");
                   break ;
        default : printf("It is a consonant");
    }
    return 0;
}

Output 1:

************************************************************************
************************************************************************
**  WAP to enter a character & tell its type vowel or consonant in C  **
**                          Created by Sheetal Garg                   **
**                            Assistant Professor                     **
**                            Phone No:9467863365                     **
************************************************************************
************************************************************************
enter a character
A
 It is a vowel

Output 2:

************************************************************************
************************************************************************
**  WAP to enter a character & tell its type vowel or consonant in C  **
**                          Created by Sheetal Garg                   **
**                            Assistant Professor                     **
**                            Phone No:9467863365                     **
************************************************************************
************************************************************************

enter a character
B
 It is a consonant
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.