C Program to Check Whether Character is Uppercase or Not

How to write a C Program to check whether the character is uppercase or not using the isupper function and by not using the isupper function?

C Program to Check Whether Character is Uppercase or Not using isupper function

In C Programming, isupper checks whether the character is an uppercase alphabet or not. This program allows the user to enter any character and check whether the character is an uppercase alphabet or not.

#include <stdio.h>
#include<ctype.h>

int main()
{
  char Ch;
 
  printf("\n Please Enter any alphabet\n");
  scanf("%c", &Ch);

  if ( isupper(Ch) )
   {  
     printf ("\n Entered character is uppercase alphabet");
   }
  else
   {
     printf("\n Entered character is Not uppercase alphabet");
   }  
}
C Program to Check Whether Character is Uppercase or Not using isupper function

In this Program, we declared a character variable Ch for Uppercase or not. The below printf statement will ask them to enter any character they like.

printf("\n Please Enter any character \n");

Below scanf statement will assign the user entered character to the Ch variable.

scanf("%c", &Ch);

In the next line, we used the If Statement. Please refer to the isupper article in C Programming,

if (isupper(Ch))

If the above condition is TRUE, the given character is an uppercase alphabet. So it will print the below statement.

printf ("\n Entered character is uppercase alphabet");

If the above condition is FALSE, the given character is not an uppercase alphabet. So, it will print the below statement.

printf ("\n Entered character is Not uppercase alphabet");

C Program to Check Whether a Character is Uppercase or Not without using isupper function

This program allows the user to enter any character and check whether the character is an uppercase alphabet or not without using the isupper function.

#include <stdio.h>

int main()
{
  char Ch;

  printf("\n Please Enter any alphabet\n");
  scanf("%c", &Ch);

  if (Ch >= 'A' && Ch <= 'Z')
   {  
     printf ( "\n Entered character is uppercase alphabet") ;
   }
  else
   {
     printf("\n Entered character is Not uppercase alphabet");
   } 
}

Uppercase or not output.

C Program to Check Character is Uppercase without using isupper

Let us check with a false value.

 Please Enter any alphabet
z

 Entered character is Not uppercase alphabet

In this c program to check character is uppercase, If you look at the If Statement.

if (Ch >= 'A' && Ch <= 'Z')

As we all know, all the uppercase characters are between A and Z. So, the above if condition will check whether the given character is between A and Z.

If the above condition is TRUE, the given character is an uppercase alphabet. So, it will print the below statement.

printf ("\n Entered character is uppercase alphabet");

If the above condition is FALSE, the given character is not an uppercase alphabet. So, it will print the below statement.

printf ("\n Entered character is Not uppercase alphabet");

C Program to Check Whether Character is Uppercase or Not using ASCII Values

This program for uppercase uses ASCII values to check whether the character is an uppercase alphabet or not. Within this Program to Check Whether the Character is Uppercase or Not example, If you look at the If Statement.

The ASCII values of all the uppercase characters are between 65 and 90. So, the above if condition will check whether the given character is between 65 and 90.

  • If the above condition is TRUE, the given character is an uppercase alphabet.
  • If the condition is FALSE, the character is not uppercase alphabet So, and it prints the else statement.
#include <stdio.h>

int main()
{
  char Ch;
  
  printf("\n Please Enter any character\n");
  scanf("%c", &Ch);

  if (Ch >= 65 && Ch <= 90)
   {  
     printf ( "\n Entered character is uppercase alphabet") ;
   }
  else
   {
     printf("\n Entered character is Not uppercase alphabet");
   }  
}
C Program to Check Character is Uppercase using ASCII Values