Home / Programs / Accept a character from the user and find it is a vowel or not without using any loop
Programming Example

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

👁 1,261 Views
💻 Practical Program
📘 Step by Step Learning
Accept a character from the user and find it is a vowel or not without using any loop

Program Code

// 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

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.