The Program in C that determines whether the Character Entered is a capital letter, a small letter, special character is given below:
#include <stdio.h>
int main() {
char ch;
printf("Enter a character: ");
scanf("%c", &ch);
if (ch >= 'A' && ch <= 'Z')
printf("'%c' is a capital letter.\n", ch);
else if (ch >= 'a' && ch <= 'z')
printf("'%c' is a small letter.\n", ch);
else if (ch >= '0' && ch <= '9')
printf("'%c' is a digit.\n", ch);
else
printf("'%c' is a special symbol.\n", ch);
return 0;
}
Output:
Enter a character: 23
‘2’ is a digit.
Pro-Tips💡
This program prompts the user to enter a character, then uses a series of if-else statements to check the character entered by the user.
If the character is between ‘A’ and ‘Z’ (inclusive) in the ASCII table, it is considered a capital letter.
If the character is between ‘a’ and ‘z’ (inclusive) in the ASCII table, it is considered a small letter.
If the character is between ‘0’ and ‘9’ (inclusive) in the ASCII table, it is considered a digit. If none of the above conditions are met, then the character is considered a special symbol.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.