Accept a character from the user and find it is a vowel or not without using any loop

C Programming Language Decision Making of C Language (Article) Decision Making of C Language (Program)

1169

Program:

// Accept a character from the user and find it is a vowel or not without using any loop
#include <stdio.h>
 
int main()
{
  char ch;
 
  printf("Input 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("%c is a vowel.\n", ch);
      break;
    default:
      printf("%c isn't a vowel.\n", ch);
  }              
 
  return 0;
}

Output:

Input a character
E
E is a vowel.
Press any key to continue . . .

Explanation:

This program is done using the concept of switch case

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.