Write a C C++ program to check vowel or consonant

Write a C C++ program to check vowel or consonant

Switch statement और multibranching statements के बारे में अधिक जानने के लिए देखें—Switch statements in C

C Language में उपलब्ध Operators और इनके विभिन्न प्रकारो को जानने के लिए देखें—Operators in C

Flowchart to check vowel or consonant

Find Vowel or Consonant flowchart

C program to check vowel or consonant

#include<stdio.h>
int main()
{
    char letter;
    printf("Enter a letter: ");
    scanf("%c",&letter);
    switch(letter)
    {
        case 'a':
        case 'A':
        case 'e':
        case 'E':
        case 'i':
        case 'I':
        case 'o':
        case 'O':
        case 'u':
        case 'U':
        printf("Vowel");
        break;
        default:
        printf("Consonant");
    }
    return 0;
}

C++ program to check vowel or consonant

#include<iostream>
using namespace std;
int main()
{
    char letter;
    cout<<"Enter a letter: ";
    cin>>letter;
    switch(letter)
    {
        case 'a':
        case 'A':
        case 'e':
        case 'E':
        case 'i':
        case 'I':
        case 'o':
        case 'O':
        case 'u':
        case 'U':
        cout<<"Vowel";
        break;
        default:
        cout<<"Consonant";
    }
    return 0;
}

Output of C C++ program to check vowel or consonant

Enter a letter: A
Vowel
Enter a letter: Z
Consonant

Other branching statement programs in C C++

  1. Absolute value of number (simple if)
  2. Checking odd or even number (if else)
  3. Checking leap year (if else)
  4. Greater in two numbers (if else)
  5. Finding grade from percent (else if ladder)
  6. Total percent and division (else if ladder)
  7. Greatest in three numbers (nested if)
  8. Simple calculator program (switch case single case)
  9. Switch between Mon to Sun (switch case single case)
  10. Number of days in a month (switch case multiple case)
  11. Unconditional Branching (break continue and goto)
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer