Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
C program to check whether a character is an Alphabets or Not

C program to check whether a character is an Alphabets or Not

Posted on February 26, 2022April 25, 2022

Table of Contents

  • C program to check whether a character is an Alphabets or Not
    • Code to check character is Alphabet or Not
      • Code to check the character is Alphabet or Not using if-else
      • Code to check the character is Alphabet or Not using Ascii
      • Code to check the character is Alphabet or Not using isalpha() function

C program to check whether a character is an Alphabets or Not

In this article, we will discuss the concept of C program to check whether a character is an Alphabets or Not

In this post, we are going to learn how to write a program to  check whether given character is English alphabet or not  using  various ways in C language

Code to check character is Alphabet or Not

Code to check the character is Alphabet or Not using if-else

In this code, we are going to learn how to check  the given character is  English alphabet or not using if else statement in C language

Program 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;//declare a character variable
//Ask to enter the character from user
    printf("Enter a character as you wish\n");
    //Storing the entered character in variable ch
    scanf("%c",&ch);
    if((ch>='A' && ch<='Z')||(ch>='a' && ch<='z')){
printf("%c is an Alphabet: ",ch);
// If the character  is an alphabet, it displays
}
else
{
printf("%c is not an Alphabet: ",ch);
}// If the character  is not an alphabet, it displays
getch();
    return 0;
}

When the above code is executed, it produces the following result

Case 1

Enter a character as you wish
T
T is an Alphabets

 

Case 2

Enter a character as you wish
x
x is an Alphabets

 

Case 3

Enter a character as you wish
&
& is not an Alphabets

 

Code to check the character is Alphabet or Not using Ascii

In this code, we are going to learn how to check  the given character is  English alphabet or not using Ascii value in C language

Program 2

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;//declare a character variable
//Ask to enter the character from user
    printf("enter a character as you wish\n");
    //Storing the entered character in variable ch
    scanf("%c",&ch);
    if((ch>=97 && ch<=122)||(ch>=65 && ch<=90)){
printf("%c is an Alphabet: ",ch);
// If the character  is an alphabet, it displays
}
else
{
printf("%c is not an Alphabet: ",ch);
}// If the character  is not an alphabet, it displays
getch();
    return 0;
}

When the above code is executed, it produces the following result

Case 1

Enter a character as you wish
M
M is an Alphabets

 

Case 2

Enter a character as you wish
c
c is an Alphabets

 

Case 3

Enter a character as you wish
#
# is not an Alphabets

 

Code to check the character is Alphabet or Not using isalpha() function

In this code, we are going to learn how to check  the given character is  English alphabet or not using isalpha() function in C language

Program 3

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char c;//declare a character variable
    printf("Enter a character\n");
    scanf("%c",&c);//ask and store a character
    if(isalpha())//check the character is alphabet or not
        printf("%c is an Alphabet",c);

    else
         printf("%c is not an Alphabet",c);
    getch();
    return 0;
}

When the above code is executed, it produces the following result

Case 1

Enter a character as you wish
E
E is an Alphabets

 

Case 2

Enter a character as you wish
v
v is an Alphabets

 

Case 3

Enter a character as you wish
*
* is not an Alphabets

 

Suggested post

if statement in C language

Function in C language

Operator in C language

 

Similar post

Java program to print all alphabets in given range

C program to print all alphabets in given range

C++ program to print all alphabets in given range

 

Java program to print all alphabets using loops

C program to print all alphabets using loops

C++ program to print all alphabets using loops

 

Java program to check whether a character is Alphabet or Not

C++ program to check whether a character is Alphabet or Not

C program to check whether a character is Alphabet or Not

Python program to check whether a character is Alphabet or Not

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes