Question
Program in C to Check the type of character (Alphabet, Digit, Special).
Solution
β Verified
#include <stdio.h>
int main() {
char ch;
printf("Enter a character: ");
scanf(" %c", &ch); // Note the space before %c to catch whitespace
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
printf("It's an alphabet.\n");
else if (ch >= '0' && ch <= '9')
printf("It's a digit.\n");
else
printf("It's a special character.\n");
return 0;
}
Click here to download practice questions on
If Else StatementMore Questions on If Else Statement
Question 2
Check if a person can vote and also check if they are a senior citizen using nested if.
View solution
Question 8
Write a program in C to Check whether a character is uppercase or lowercase.
View solution
Question 12
Write a program in C to Check if a person is eligible to vote by checking his or her age.
View solution