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 isupper function and by not using isupper function?

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

In C Programming, isupper check 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");
   }  
}
Character is Uppercase or not using islower

In this C Program to Check Whether Character is Uppercase, we declared a character variable Ch. Below printf statement will ask to enter any character he likes.

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

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

scanf("%c", &Ch);

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

if (isupper(Ch))

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

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

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

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

Program to Check Whether 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 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");
   } 
}

C uppercase or not output

 Please Enter any alphabet
A

 Entered character is uppercase alphabet

Let us check with a false value

 Please Enter any alphabet
z

 Entered character is Not uppercase alphabet

In this c uppercase program, 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 then the given character is an uppercase alphabet So, it will print below statement

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

If the above condition is FALSE then the given character is not uppercase alphabet So, it will print 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.

#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");
   }  
}
 Please Enter any character
Z

 Entered character is uppercase alphabet

Within this C Program to Check Whether Character is Uppercase or Not example, If you look at the If Statement

if (Ch >= 65 && Ch <= 90)

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. So, it will print the below statement

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

If the condition is FALSE, the character is not uppercase alphabet So, and it prints below statement.

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