c
of data type char
. We then prompt the user to enter a character using the printf
and scanf
functions.if-else
statements to determine if the entered character is an uppercase or lowercase letter. The first condition checks if the character is an uppercase letter by checking if it falls within the ASCII range for uppercase letters. If the character is an uppercase letter, the program prints the message “c is an uppercase letter.”.#include <stdio.h> int main() { char c; printf("Enter a character: "); scanf("%c", &c); if (c >= 'A' && c <= 'Z') { printf("%c is an uppercase letter.", c); } else if (c >= 'a' && c <= 'z') { printf("%c is a lowercase letter.", c); } else { printf("%c is not a letter.", c); } return 0; }
Enter a character: A
A is an uppercase letter.
Enter a character: b
b is a lowercase letter.
Enter a character: #
# is not a letter.