✓ Link copied to clipboard
C 📅 July 4, 2026 ⏱ 5 min read

C Program to Check Whether a Character is an Alphabet

C Program to Check Whether a Character is an Alphabet

Sometimes you need to check if a character is a letter, like A or z. That's where this C program comes in handy. It checks whether the character you provide is an alphabet. If you've got a program that needs to tell apart alphabets and other characters, like numbers or symbols, this will do the job. When you run this program, you'll see how it evaluates both uppercase and lowercase letters.

Prerequisites for the Check Character Alphabet Program in C

Before you write this program, ensure you understand:

  • Using #include <stdio.h> for I/O functions
  • char data type for characters
  • The relational operators >= and <=
  • Any C compiler such as GCC 9 or newer — or just run it in the EduSeekho online compiler

Source Code of C Program to Check Whether a Character is an Alphabet or not

Here's the complete code to determine if a character is an alphabet:

alphabet_check.cC▶ Run
#include <stdio.h>

int main() {
    char ch;
    printf("Enter a character: ");
    scanf(" %c", &ch);

    // Check if ch is an alphabet
    if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
        printf("It is an alphabet.\n");
    } else {
        printf("It is not an alphabet.\n");
    }

    return 0;
}

Try this code yourself — free

Run it in the EduSeekho online compiler. No setup needed.

▶ Open Compiler

Output of the Check Character Alphabet Program

Here's what you can expect when you run the program:

OUTPUTtext▶ Run
Enter a character: A
It is an alphabet.

Enter a character: 1
It is not an alphabet.
Output of C Program to Check Whether a Character is an Alphabet or not
Output of C Program to Check Whether a Character is an Alphabet or not

Algorithm to Check a Character in C

To determine if a character is an alphabet, the program checks its ASCII value. Here's the step-by-step logic.

  1. Read the character input from the user.
  2. Check if the character is between 'A' and 'Z' or between 'a' and 'z'.
  3. If true, print that it is an alphabet.
  4. If false, print that it is not an alphabet.
flowchart TD
  A([Start]) --> B[/Read a character/]
  B --> C{Is character an alphabet?}
  C -->|Yes| D[Print "It is an alphabet."]
  C -->|No| E[Print "It is not an alphabet."]
  D --> F([End])
  E --> F
Flowchart: the algorithm step by step

How the C Program to Check Character Alphabet Works

Let's walk through how this program works, line by line:

  • The program begins with the #include <stdio.h> directive to allow input and output operations.
  • We declare a char variable ch to store the character input.
  • printf("Enter a character: "); prompts the user to input a character.
  • scanf(" %c", &ch); reads the character and stores it in ch.
  • The if statement checks if ch is an alphabet using conditions ch >= 'A' && ch <= 'Z' for uppercase and ch >= 'a' && ch <= 'z' for lowercase.
  • If true, printf("It is an alphabet.\n"); executes.
  • Otherwise, the else block executes printf("It is not an alphabet.\n");.
  • Finally, return 0; indicates the program has finished successfully.
🧠

Quick Quiz — test your understanding

Tap an option to check your answer

Which ASCII range represents uppercase alphabets?

🎉Correct! The correct range for uppercase alphabets is 65 to 90.
🤔Not quite. Think about the ASCII values for 'A' to 'Z'.

Time and Space Complexity of the Check Character Alphabet Program in C

Analyzing the performance of this program is straightforward.

Time Complexity: O(1). Since this program performs a fixed number of operations to check the character, the time taken doesn’t increase with input size. It evaluates the conditions ch >= 'A' and ch <= 'Z' directly.

Space Complexity: O(1). The program only uses a single char variable ch, which means memory usage is constant regardless of input.

⚠️

Common mistake:Forgetting to use the logical OR operator || correctly can lead to incorrect results. Make sure both uppercase and lowercase checks are there.

Key takeaway:This program efficiently checks a single character with minimal resources.

FAQs About Checking Character Alphabet in C

Here are answers to some common questions about this program:

To check for vowels, just extend the same logic and see if the character is one of 'a', 'e', 'i', 'o', 'u' (and their uppercase versions).
The program will show that it's not an alphabet since the conditions for alphabets don't match numeric characters.
Yep, special characters won't meet the conditions for alphabets and will be labeled as non-alphabets.
ASCII values make it easy to differentiate between characters like digits, letters, and symbols using numeric codes.
Nope, this program only checks basic alphabets. To support accented characters, you'd need to handle extended ASCII or Unicode.

If you found this program helpful, check out these related programs:

Conclusion

Checking if a character is an alphabet is a basic yet essential operation in many applications. It's a straightforward program that shows character handling in C. If you're curious about character manipulation, try playing around with vowel checking next. You'll find that tweaking this code can teach you even more about conditional logic and ASCII values.

Ready for more practice? Test your skills with the C language quiz and try modifying this code in the EduSeekho online compiler.