isupper in C Programming

The C isupper function is one of the Standard Library Functions available in the C language. The C isupper function checks whether the given character is an uppercase alphabet or not.

C isupper Function syntax

The below isupper in C Programming function will accept a single character as the parameter and find whether the given character is in uppercase or not.

isupper(char)

The isupper is a built-in function present in the <ctype.h> header file is used to check whether the character is an uppercase alphabet or not. The Syntax of the C isupper function is

isupper (<character>);

The C isupper function will return an integer value as output.

  • If the character inside the isupper function is in uppercase, it will return a non zero value.
  • If the character is not in uppercase, it will return 0.

isupper in C Programming Example

The isupper function is used to find whether the given character is an uppercase character or not. This C program allows the user to enter any character and check whether the character is between A to Z using this function.

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

int main()
{
    char ch;
    printf("Please Enter Any Uppercase Character: \n");
    scanf("%c", &ch);

    if(isupper(ch))
    {
      printf("\n You have entered an Uppercase Character");         
    }
    else
    {
      printf("\n %c is not an Uppercase Alphabet", ch);
      printf("\n I request you to enter Valid Uppercase Character");	
    }
}
isupper in C Programming 1

Let me enter the lowercase letter.

Please Enter Any Uppercase Character: 
b

 b is not an Uppercase Alphabet
 I request you to enter Valid Uppercase Character

Analysis

First, we declared a character variable called ch. The following C Programming statement will ask the user to enter any character. And then, we use the scanf to assign the user entered character to the ch variable.

printf("Please Enter Any Uppercase Character: \n");
scanf("%c", &ch);

Next, we used the If Statement to check whether the character is between ‘A’ and ‘Z’ or not using the C isupper function. If the condition is True, the following statement will print

printf("\n You have entered an Uppercase Character");

If the above If Statement is FALSE, the given character is not a lowercase Alphabet. So, it will print the below statements.

printf("\n %c is not an Uppercase Alphabet", ch);
printf("\n I request you to enter Valid Uppercase Character");

The above code will check whether the given character is an uppercase character or not, but what if we enter the numeric value?

Please Enter Any Uppercase Character: 
7

 7 is not an Uppercase Alphabet
 I request you to enter Valid Uppercase Character

Please refer to the C Program to check whether the Character is Uppercase or Not article. It helps you understand how to check whether the character is an uppercase alphabet without using the isupper function.