isupper()
is a C library function that checks whether or not the character passed as a parameter is an uppercase letter.
#include<ctype.h>
Below is the declaration of isupper()
,
int isupper(int ch);
where ch
is the character to be checked. The return type of the function is int
.
If the letter passed to the function is an uppercase letter, the function returns a non-zero value. Otherwise, the function returns zero.
An alternative approach (without using isupper()
) to check whether or not a character is an uppercase letter is to check if the character lies between and (inclusive).
If the character lies between and (inclusive), it is an uppercase letter. Otherwise, it is not.
isupper()
#include<stdio.h>#include<ctype.h>int main() {char str[] = {'a', '!', '2', 'M'};int i = 0;while (i < 4) {int returnValue = isupper(str[i]);if (returnValue > 0)printf("%c is an uppercase letter.\n", str[i]);elseprintf("%c is not an uppercase letter.\n", str[i]);++i;}return 0;}
isupper()
#include<stdio.h>#include<ctype.h>int main() {char str[] = {'a', '!', '2', 'M'};int i = 0;while (i < 4) {if (str[i] >= 65 && str[i] <= 90)printf("%c is an uppercase letter.\n", str[i]);elseprintf("%c is not an uppercase letter.\n", str[i]);++i;}return 0;}
Free Resources