Check vowel or consonant using if else ladder in C Programming

  • Tech Area
  • May 11, 2024



In this tutorial, We will see how to check vowel or consonant using if else ladder in C programming language. If else ladder statement allows to execute certain code blocks based on specific conditions. 

The syntax of the if else ladder statement is:

if (condition 1)
{
    // run code if condition 1 is true
}
else if (condition 2)
{
    // run code if condition 2 is true
}
else if (condition 3)
{
    // run code if condition 3 is true
}
else
{
    // run code if above conditions are false
}

Program to check vowel and consonant using if else ladder

#include<stdio.h>
#include<conio.h>
void main()
{
char c;
clrscr();
printf("Enter any character = ");
scanf("%c", &c);
if(c == 'A' || c == 'a')
{
printf("%c is vowel", c);
}
else if(c == 'E' || c == 'e')
{
printf("%c is vowel", c);
}
else if(c == 'I' || c == 'i')
{
printf("%c is vowel", c);
}
else if(c == 'O' || c == 'o')
{
printf("%c is vowel", c);
}
else if(c == 'U' || c == 'u')
{
printf("%c is vowel", c);
}
else
{
printf("%c is consonant", c);
}
getch();
}

Output

Enter any character = a
a is vowel

The character a entered by the user is stored in the c variable. Since the c is a, the control of the program go to if block.

if(c == 'A' || c == 'a')
{
printf("%c is vowel", c);
}


Subscribe us via Email

Join 10,000+ subscriber

Subscribe on YouTube