Check Alphabet is upper or lower case
Table of Contents
In this article, we will discuss the concept of C++ program: Check whether the given Alphabet is upper or lower case
In this post, we are going to learn how to write a program to check whether given Alphabet is Upper case or lower case using if else in C++ language
In this code, we are going to learn how to check the given Alphabet is Upper case or lower case or not using if else statements in C++ language
Program 1
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char ch;//declare character variable
cout<<"Enter an Alphabet: ";
//Ask input from the user
cin>>ch;//reading the input
if(ch>='A' && ch<='Z'){//check upper case letter
cout<<ch<<" is an upper case letter ";
}
else{//Display if it is not upper case
cout<<ch<<" is a lower case letter ";//lower case
}
getch();
return 0;
} When the above code is executed, it produces the following result
Case 1
Enter an Alphabet: H H is an upper case letter
Case 2
Enter an Alphabet: t t is a lower case letter
In this code, we are going to learn how to check the given Alphabet is Upper case or lower case or not using if else statements in C++ language
Program 2
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char ch;//declare character variable
cout<<"Enter an Alphabet: ";
//Ask input from the user
cin>>ch;//reading the input
if(ch>=65 && ch<=90){//check upper case letter
cout<<ch<<" is an upper case letter ";
}
else{//Display if it is not upper case
cout<<ch<<" is a lower case letter ";
}//this means lower case
getch();
return 0;
}
When the above code is executed, it produces the following result
Case 1
Enter an Alphabet: H H is an upper case letter
Case 2
Enter an Alphabet: t t is a lower case letter
Suggested post
Switch statements in C++ language
Similar post
Java program to print all alphabets in given range
C program to print all alphabets in given range
C++ program to print all alphabets in given range
Java program to print all alphabets using loops
C program to print all alphabets using loops
C++ program to print all alphabets using loops
Java program to check whether a character is Alphabet or Not
C++ program to check whether a character is Alphabet or Not
C program to check whether a character is Alphabet or Not
Python program to check whether a character is Alphabet or Not
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.