Table of Contents
C program: check whether given Alphabet is upper case or lower case
In this article, we will discuss the concept of C Program: check whether 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
Code to check given Alphabet is Upper or Lower
Code to check given Alphabet is Upper or Lower case, using if statements
In this code, we are going to learn how to check the given Alphabet is Upper case or lower case using if else statements in C language
Program 1
#include <stdio.h> #include <stdlib.h> int main() { char ch; //input character from user printf("Input any character: "); scanf("%c",&ch); if(ch >='A' && ch<= 'Z') {//check if the given Alphabets is upper case printf("'%c' is an Upper case Alphabet",ch); } else{ printf("'%c' is a lower case Alphabet",ch); }//Display, if the character is not an English alphabet getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Input any Alphabet: M 'M' is an Upper case Alphabet
Case 2
Input any Alphabet: x 'x' is a Lower case Alphabet
Code to check given Alphabet is Upper or Lower case, using Ascii
In this code, we are going to learn how to check the given Alphabet is Upper case or lower case using Ascii value in C language
Program 2
#include <stdio.h> #include <stdlib.h> int main() { char ch; //input character from user printf("Input any character: "); scanf("%c",&ch); if(ch >=65 && ch<= 90) {//check if the given Alphabets is upper case printf("'%c' is an Upper case Alphabet",ch); } else{ printf("'%c' is a lower case Alphabet",ch); }//Display, if the character is not an English alphabet getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Input any Alphabet: O 'O' is an Upper case Alphabet
Case 2
Input any Alphabet: p 'p' is a Lower case Alphabet
Code to check given Alphabet is Upper or Lower case, using library function
In this code, we are going to learn how to check the given Alphabet is Upper case or lower case using per-defined library function in C language
Program 3
#include <stdio.h> #include <ctype.h> int main() { char ch; //input character from user printf("Input any Alphabet: "); scanf("%c",&ch); if(isupper(ch)) {//check if the given Alphabets is upper case printf("'%c' is an Upper case Alphabet",ch); } else if(islower(ch)) {//check if the given Alphabets is lower case printf("'%c' is a Lower case Alphabet",ch); } getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Input any Alphabet: W 'W' is an Upper case Alphabet
Case 2
Input any Alphabet: u 'u' is a Lower case Alphabet
Suggested post
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