C isupper() Function Tutorial

  • Post author:
  • Post category:C

In this section, we will learn what the isupper() function is and how to use it in C.

isupper() function in C

The `isupper()` function is used to check whether a character is an `uppercase alphabet`. (A-Z)

The prototype of the function exists in the `ctype.h` header file and we need to include this header file in order to use the ` isupper ()` function.

isupper() Function Syntax

Here’s the prototype of the ` isupper ()` function:

int isupper (int argument);

isupper() Function Parameters

This function takes one argument and that is the character that we want to check.

isupper() Function Return Value

The return value of the function is:

  • 0: If the character was not an `uppercase alphabet`.
  • Positive value: if the character was in fact an `uppercase alphabet`.

Example: checking capital letter in C via isupper() function

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

int main() {

    char character = 'B';
    char c2 = 'b';

    printf("The first character: %d \nThe second character: %d", isupper (character), isupper (c2));

    return  0;
}

Output:

The first character: 1

The second character: 0

The first character in this example is `B` and so the result of calling the `isupper` function is a positive value because `B` is an uppercase alphabet character. But the result of the second character is 0 because the actual value of the character is `b` and it’s not an `uppercase alphabet character`.

Leave a Reply