In this article, we will discuss the concept of the C Check whether the given alphabet is uppercase or lowercase
In this post, we are going to learn how to check the given alphabet is in upper case or lowercase in C programming language
The program allows to enter an character, thereafter it checks and displays whether the given character an upper case or lower case or not
Program 1
#include <stdio.h> #include <stdlib.h> int main() { char ch; printf("Enter a character: "); scanf("%C",&ch); if(ch>='A' && ch<='Z'){ printf("%c is an upper case letter ",ch); } else if(ch>='A' && ch<='z'){ printf("%c is a lower case letter ",ch); } else{ printf("%c is not a Alphabets ",ch); } getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Enter a character: D D is an upper case letter
Case 2
Enter a character: g g is a lower case letter
Case 3
Enter a character: $ $ is not an Alphabets
Approach
The program allows to enter an character, thereafter it checks and displays whether the given character an upper case or lower case using ASCII value
Program 2
#include <stdio.h> #include <stdlib.h> int main() { char ch;//character variable declaration printf("Enter a character: "); scanf("%C",&ch);//store the entered value if(ch>=65 && ch<=90){ printf("%c is an upper case letter ",ch); } else if(ch>=97 && ch<=122){ printf("%c is a lower case letter ",ch); } else{ printf("%c is not a Alphabets ",ch); } getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Enter a character: A A is an upper case letter
Case 2
Enter a character: v v is a lower case letter
Case 3
Enter a character: & & is not an Alphabets
Approach
Suggested for you
Similar post
Check whether the given alphabet is in upper case or lowercase in Java
Check whether the given alphabet is in upper case or lowercase in Python
Check whether the given alphabet is in upper case or lowercase in C++
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…