isupper in C Programming

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

C isupper Function syntax

The Below function will accept a single character as the parameter, and find whether the given character is in uppercase or not.

isupper(char)

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

isupper (<character>);

The isupper function will return an integer value as output.

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

isupper in C Programming Example

The isupper function 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 the isupper function.

//Example for isupper in C Programming
#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

First, we declared a character variable called ch. The following C Programming statement will ask the user to enter any character. And then, we are using the scanf to assign the user entered character to 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 condition 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 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 or not without using the isupper function