isupper() function in C Language
isupper() function in C programming checks whether the given character is upper case or not. isupper() function is defined in ctype.h header file.
Syntax :
int isupper ( int x );
Examples:
Input: A
Output: Entered character is uppercase character
Input: a
Output: Entered character is not uppercase character
Input: 1
Output: Entered character is not uppercase character
C
#include <ctype.h>
#include <stdio.h>
int main()
{
char ch = 'A' ;
if ( isupper (ch))
printf ( "\nEntered character is uppercase character" );
else
printf ( "\nEntered character is not uppercase character" );
}
|
Output:
Entered character is uppercase character
Application : isupper() function in C programming language is used to find out total number of uppercase present in a given sentence.
Example:
Input: GEEKSFORGEEKS
Output: Number of upper case present in the sentence is : 13
Input: GeeksFORGeeks
Output: Number of upper case present in the sentence is : 5
Input: geeksforgeeks
Output: Number of upper case present in the sentence is : 0
C
#include <ctype.h>
#include <stdio.h>
int ttl_upper( int i, int counter)
{
char ch;
char a[50] = "GeeksForGeeks" ;
ch = a[0];
while (ch != '\0' ) {
ch = a[i];
if ( isupper (ch))
counter++;
i++;
}
return (counter);
}
int main()
{
int i = 0;
int counter = 0;
counter = ttl_upper(i, counter);
printf ( "\nNumber of upper case present in the sentence is : %d" , counter);
return 0;
}
|
Output:
Number of upper case present in the sentence is : 3
Last Updated :
27 Sep, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...