C Program to Check Whether a Character is Vowel or Consonant

devquora
devquora

Posted On: Jan 27, 2023

C Program to Check Whether a Character is Vowel or Consonant

 

Overview:

In this Article, I would like to tell the logic for the C Program to Check Whether a Character is Vowel or Consonant. But, First of all let's understand what is Alphabet?What are the Vowels? and What are the consonants? After that, I will show a Visual representation for the Alphabet, Vowel and Consonant. After all, I will write the logic and C Program to Check Whether a Character is Vowel or Consonant with output.

Table of contents:

  1. What do you mean by Alphabet?
  2. What are the Vowels?
  3. What are the consonants?
  4. Visual representation for the Alphabet, Vowel and Consonant
  5. Logic to Check Whether a Character is Vowel or Consonant
  6. C Program to Check Whether a Character is Vowel or Consonant with output
  7. Conclusion

What do you mean by Alphabet?

The Alphabet is a set of letters with which one or more languages are written, especially if arranged in a customary order. The Sequence of each letter in the Alphabet is predefined. For instance, The Sequence A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z is known as the Alphabet that represent the Capital letters in the Alphabet. The Alphabet has a total 26 characters. You can denote these letters as small letters such as a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z but can not change the position of the letter in the Alphabet.

What are the Vowel?

Lowercase English alphabets a, e, i, o, u and uppercase English alphabets A, E, I, O, U are called Vowels. All other alphabets are called Consonants. Use 'an' before a vowel sound. These are the speech sounds produced by humans when the breath flows out through the mouth without being blocked by the teeth, tongue, or lips.

What are the Consonant?

Consonant is one of the speech sounds of letters in the alphabet that is not a vowel. Consonants are pronounced by stopping the air from flowing easily through the mouth, especially by closing the lips or touching the teeth with the tongue. Consonant denotes a consonant sound or letter such as B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z.

Visual representation for the Alphabet, Vowel and Consonant

Alphabet, Vowel,  Consonant

Logic to Check Whether a Character is Vowel or Consonant

  • Step 1: The character entered by the user is stored in variable ch
  • Step 2: Compare it with Vowels ASCII values. Is it true then print this character is Vowel.
  • Step 3: In else if block, compare it with consonent's ASCII code. If the condition is true then print this character is Consonant.
  • Step 4: Otherwise print this character is not a letter of the alphabet.

C Program to Check Whether a Character is Vowel or Consonant with output

// C Program to Check Whether it is Vowel or Consonant
#include 
 
int main()
{
    char ch;
 
    printf("Please Enter an alphabet: \n");
    scanf(" %c", &ch);
 
    if(ch == 97 || ch == 101 || ch == 105 || ch == 111 || ch == 117 || 
	ch == 65 || ch == 69 || ch == 73 || ch == 79 || ch == 85)
    {
    	printf("%c is a VOWEL.\n", ch);
    }
    else if((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90))
    {
        printf("%c is a CONSONANT.\n", ch);
    }
	else
	{
		printf("%c is not a Alphabet character.\n", ch);
	}
    return 0;
}

The output of the Program with code:

When the above code is executed, it produces the following results:

Please Enter an alphabet:
A
A is a VOWEL.

Check whether character is vowel or consonant Output

Conclusion:

In this Program, the if…else statement is used to check whether an alphabet entered by the user is a vowel or a constant. The five letters A, E, I, O and U are called vowels. All other letters except these 5 vowel letters are called consonants. This program assumes that the user will always enter an alphabetic character.

    Please Login or Register to leave a response.

    Related Articles

    C Program Examples

    C Program to convert Decimal to Binary Number

    A Decimal Number is constructed with any digit from 0 to 9. For instance, 24 is a Decimal Number constructed from the digits 2 and 4. A Binary Number is constructed with digits 0 and 1. For instance, ..

    C Program Examples

    C program to reverse a string

    This program reversed the entered string that means opposite of the previous string sequence...

    C Program Examples

    C program to reverse an Integer number

    Are you want a demonstration of The C Program that reverses an Integer number? This Program reversing the sequence of digits in an Integer. After the successful compilation of the program, a message..