C Program to Check Whether a Character is an Alphabet or not

devquora
devquora

Posted On: Dec 15, 2020

C Program to Check Whether a Character is an Alphabet or not

 

Overview:

In this Article, I would like to tell the logic for the C Program to Check Whether a Character is Alphabet or not. But, First of all let's understand what the Alphabet is. Moreover, 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. Visual representation for the Alphabet, Vowel and Consonant
  3. Logic to Check Whether a Character is Vowel or Consonant
  4. C Program to Check Whether a Character is Vowel or Consonant with output
  5. 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.

Visual representation for the Alphabet, Vowel and Consonant

Alphabet demo

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 All alphabet's ASCII values. Is it true then print this character is an Alphabet.
  • Step 4: Otherwise print this character is not an Alphabet.

C Program to Check Whether a Character is an Alphabet or not

#include <stdio.h>

int main()
{
  char ch;
  printf("\n Please Enter any character: ");
  scanf("%c", &ch);
  
  if( (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') )
    printf("\n %c is an Alphabet.",ch);
  else
    printf("\n %c is not an Alphabet., ch);
  
  return 0;
}

The output of the Program with code:

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

Please Enter any character: #

# is not an Alphabet.

Armstrong checker Output

Conclusion:

In this Program, the if…else statement is used to check whether a character entered by the user is alphabet or not? The alphabets 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, and Z are called Alphabet. All other charaters except these 26 letters are not an Alphabet. If User entered any character rather than 26 Alphabet than a print like # is not an alphabet.

    Related Questions

    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..