Adsense 728 * 15

Search

Custom Search

C, C++ Program to Check whether a Character is Vowel or not

Write a C, C++ program to check whether a character is vowel or not.  In this program, We take a input character from user and our code will check whether a input character is vowel or not.


How to Check whether a Character is Vowel or not


1.  Take input character from user.

2.  Compare input character with a,e,i,o,u,A,E,I,O,U. If it matches with any of them then it's a vowel.

Program to count number of vowels in a string

Programming questions on Strings


C++ Program to Check whether a Character is Vowel or not.

#include <iostream>
using namespace std;

int main() {

      /* Declare char. */
 
      char alpha;

      /* Take a input character from user. */

      cout<<" Enter a character\n";
      cin >> alpha;

      if ( alpha == 'a' || alpha == 'A'  
           || alpha == 'e' || alpha == 'E' 
           || alpha == 'i' || alpha == 'I' 
           || alpha =='o' || alpha=='O' 
           || alpha == 'u' || alpha == 'U') {

         cout<<"Entered character is a vowel";
      } else {
          cout<<"Entered character is not a vowel";
       }

       return 0;
}


Output:

Enter a character :  a

Entered character is a vowel.


C Program to Check Whether a Character is Vowel or Not


#include <stdio.h>

int main(void) {
 
      char alpha;

      /* Take a input character from user. */

      printf(" Enter a character\n");
      scanf("%c", &alpha);

      if ( alpha == 'a' || alpha == 'A' 
           || alpha == 'e' || alpha == 'E' 
           || alpha == 'i' || alpha == 'I' 
           || alpha =='o' || alpha=='O' 
           || alpha == 'u' || alpha == 'U') {

         printf("Entered character is a vowel");
      } else {
         printf("Entered character is not a vowel");
       }
       
 return 0;
}


Programming question on Arrays

Programming question on Linked List

Sorting algorithm and their time complexity

Stack implementation

Programming questions using Recursion

C, C++ interview questions

Programming Books

3 comments:

  1. Thank you for your help.

    ReplyDelete
  2. have tried the same program on visual studio ultimate 2012 but have found two errors.
    1. on the opening brace after the "if (condition)" it says Error: expected an expression.
    2. on the last brace that closes the whole code the error is 'expected a ')'

    ReplyDelete
  3. We can also create our custum int isVowel(char c); function to detect vowel characters. C check vowel and consonant character

    ReplyDelete