Alphabet

C Check whether the given alphabet is upper case or lowercase

C Check whether the given alphabet is upper case or lowercase

In this article, we will discuss the concept of the C Check whether the given alphabet is uppercase or lowercase

In this post, we are going to learn how to check the given alphabet is in upper case or lowercase in C  programming language

Check upper case or lower case

Check whether the given alphabet is upper case or lowercase using Alphabets

The program allows to enter an character, thereafter it checks and displays whether the given character an upper case or lower case or not

Program 1

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

int main()
{
    char ch;
    printf("Enter a character: ");
     scanf("%C",&ch);
     if(ch>='A' && ch<='Z'){
    printf("%c is an upper case letter ",ch);
}
else if(ch>='A' && ch<='z'){
    printf("%c is a lower case letter ",ch);
}
else{
    printf("%c is not a Alphabets ",ch);
}
getch();
    return 0;
}

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

Case 1

Enter a character: D
D is an upper case letter

 

Case 2

Enter a character: g
g is a lower case letter

 

Case 3

Enter a character: $
$ is not an Alphabets

 

Approach

  1. Define a variable as char ch;
  2. The user is asked to enter a character to check uppercase or lowercase
  3. The entered character is stored in ch variable
  4. Use an if statement to check uppercase if the test expression is true,  The tested Alphabet is upper case
  5. When the if-statements is false, The control moves to else if and checks the test expression of else-if
  6. If the test expression of else-if is true,  The tested Alphabet is lower case
  7. If the test expression of else if is false, control moves to else part and executes else part statement
  8. Finally, the program displays the character whether uppercase or lowercase or not

Check whether the given alphabet is in upper case or lowercase using ASCII value

The program allows to enter an character, thereafter it checks and displays whether the given character an upper case or lower case using ASCII value

Program 2

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

int main()
{
    char ch;//character variable declaration
    printf("Enter a character: ");
     scanf("%C",&ch);//store the entered value
     if(ch>=65 && ch<=90){
    printf("%c is an upper case letter ",ch);
}
else if(ch>=97 && ch<=122){
    printf("%c is a lower case letter ",ch);
}
else{
    printf("%c is not a Alphabets ",ch);
}
getch();
    return 0;
}

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

Case 1

Enter a character: A
A is an upper case letter

 

Case 2

Enter a character: v
v is a lower case letter

 

Case 3

Enter a character: &
& is not an Alphabets

 

Approach

  1. Define a variable as char ch;
  2. The user is asked to enter a character to check uppercase or lowercase
  3. The entered character is stored in ch variable
  4. Use an if statement to check uppercase if the test expression is true,  The tested Alphabet is upper case
  5. When the if-statements is false, The control moves to else if and checks the test expression of else-if
  6. If the test expression of else-if is true,  The tested Alphabet is lower case
  7. If the test expression of else if is false, control moves to else part and executes else part statement
  8. Finally, the program displays the character whether uppercase or lowercase or not

 

Suggested for you

Data type in C language

Variable in C language

The operator in C language

If statements in C language

 

Similar post

Check whether the given alphabet is in upper case or lowercase in Java

Check whether the given alphabet is in upper case or lowercase in Python

Check whether the given alphabet is in upper case or lowercase in C++

 

 

C++ Check whether the given alphabet is upper case or lowercase
Java program to check Vowel or consonant using switch case statements
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago