Table of Contents
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
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
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
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
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
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.