C <ctype.h> - isupper() Function
The C <ctype.h> isupper() function is used to check if the given character is an uppercase letter. In the default "C" locale, the following are the uppercase letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ. Other locales may consider a different selection of characters as uppercase characters.
Syntax
int isupper ( int ch );
Parameters
ch |
Specify the character to be checked, casted to an int, or EOF. |
Return Value
Returns non-zero value (i.e, true) if ch is a uppercase letter, else returns zero (i.e, false).
Example:
The example below shows the usage of isupper() function.
#include <stdio.h> #include <ctype.h> int main (){ char str[50] = "99HEllo"; //counting the number of uppercase //characters in str int i = 0, count = 0; while(str[i]) { if(isupper(str[i])) count++; i++; } //displaying the output printf("%s contains %d uppercase letters.", str, count); return 0; }
The output of the above code will be:
99HEllo contains 2 uppercase letters.
❮ C <ctype.h> Library