C++ Program to check Character is Alphabet or Not2 min read

We will write a C++ program to check whether a character is an alphabet or not. Before that, you should have knowledge of the following in C++.


Program to Check Alphabet or Not in C++

First of all the program ask the user to enter a character that needed to be checked and then starts the process of checking.

Using if-else statement if checks whether entered character is greater than or equals to a and less than or equal to z or not. Along with that, using or operator (||) another condition is checked for the uppercase alphabet that is whether entered character is greater than or equals to A and less than or equal to Z or not.

If either of the condition is true then if the part is executed otherwise else part is executed. The program is checking for both lowercase alphabet and uppercase alphabet.

Output:

//Run 1
Enter a Character: A
A is an Alphabet

//Run 2
Enter a Character: 5
5 is NOT an Alphabet


Using ASCII Value

We will do the same except we will compare the character with ASCII value.

  • The ASCII values for lowercase characters ranges between 67 to 122. (‘a’ = 97 and ‘z’ = 122).
  • The ASCII values for uppercase characters ranges between 65 to 92. (‘A’ = 65 and ‘Z’ = 90).

C++ program to check whether the entered character is alphabet or not using ASCII value.

After executing this program, it will produce the same result as the first program mentioned above.


MORE

Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …
Read More

String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …
Read More

Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …
Read More

Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …
Read More

Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …
Read More

Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …
Read More