Check character is uppercase, lowercase, digit or symbol in C
if else if - Question 4
In this question, we will see how input a character and check if it is an uppercase alphabet or lowercase alphabet or digit or a special symbol in C programming using the if else if statement. To know more about if else if statement click on the if else if statement lesson.
Q4) Write a program in C to input a character and check if it is an uppercase alphabet or lowercase alphabet or digit or a special symbol.
Program
#include <stdio.h>
#include <conio.h>
int main()
{
char c;
printf("Enter a character ");
scanf("%c",&c);
if(c>='A' && c<='Z')
{
printf("Uppercase alphabet");
}
else if(c>='a' && c<='z')
{
printf("Lowercase alphabet");
}
else if(c>='0' && c<='9')
{
printf("Digit");
}
else
{
printf("Special symbol");
}
return 0;
}
Output
Enter a character 8 Digit