Description

Write a program to find the given character is vowel or consonant.

Hello Guys... Welcome to my website.

Here we solve the a basic problem of c++ program that called how to find the vowel consonant.

So Now first off we know about what is consonant and vowel. We are better understand that that vowel is five i.e ( a, e, i, o , u ) and remaining alphabets called the consonant. So Now let's get started the code this problem...

#include<iostream>
using namespace std;
int main(){
    char ch;
    cout<<"Enter the character a to z or A to Z : ";
    cin>>ch;
    if(ch=='a'|| ch=='e' || ch=='i' || ch=='o' || ch=='u' || ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U'){
        cout<<ch<<" is Vowel";
    }
    else{
        cout<<ch<<" is Consonant";
    }
return 0;
}

Output :

 

Enter the character a to z or A to Z : a
a is Vowel

In the above program,

  • we initilized a variable that called 'ch' which store the value of given by user as a character form because we want to check the albhabet that is vowel or consonant.
  • cout<<"Enter the character a to z or A to Z :" : this is use for the print the given message for user so this use for understand the user.
  • cin : with the help of this function we take the input from user.

 After these we check the condition that is the given character is mathed the vowel ( a, e, i , o ,u ) then print the given alphabet is vowel. So here we check this condition we the help of the if statement. So Here we write the piece of code that if(ch=='a'|| ch=='e' || ch=='i' || ch=='o' || ch=='u' || ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U') , that condition is true then print the that given character is vowel otherwise that print the givne character is consonant.

After this return 0 , this is the mean that the program is successfully executed.

Thank You So Much for read this.

Comments

Login is mandatory to comment Please login

Recommended Posts

Armstrong Or Not in C

Write a program to find the given number is Armstrong or Not.

Star Pyramid Pattern in C programming

How to code the star pyramid pattern in c programming using for loop and simplied way.

Even or Odd in C | How to check given number is odd or even

How to check the given number is odd or even in C programming language.

Factorial program in C | Factorial given number by user | Factorial

Hello Guys... Here we write a program to calculate the factorial a number given by user.

Factorial Using function | C programming language

Here we calculate the factorial using function in c programming language.

Prime number program in c | Calculate given number is prime or Not | prime number

What is prime number? and how to calculate the given number is prime or not |