6.3.11 isupper Function

Test for an uppercase letter.

Include

<ctype.h>

Prototype

int isupper (int c);

Argument

c
The character to test.

Return Value

Returns a non-zero integer value if the character, c, is an uppercase alphabetic character; otherwise, returns zero.

Remarks

A character is considered to be an uppercase alphabetic character if it is in the range of 'A'-'Z'.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

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

int main(void)
{
  int ch;

  ch = 'B';
  if (isupper(ch))
    printf("B is uppercase\n");
  else
    printf("B is NOT uppercase\n");

  ch = 'b';
  if (isupper(ch))
    printf("b is uppercase\n");
  else
    printf("b is NOT uppercase\n");
}

Example Output

B is uppercase
b is NOT uppercase