Saturday, May 22, 2010

C programming question?

Please give me an example of using isupper() in C.


Just a simple example that can be run. Thank you very much.

C programming question?
isupper() :-





This Function is used to check whether the character is in uppercase (A to Z) or not. The format of this funtion is:





returnvalue=isupper(character);





Dear friend, here the returnvalue should be integer type. If your character is in uppercase then it will return true (non-zero value) otherwise it will return false (zero value). Here you can pass either the character variable or character constant as argument.





For Example:





int returnvalue;


returnvalue=isupper('A');





Here the value of the returnvalue is non-zero since the 'A' is in uppercase. This function is written in "ctype.h (Library Header File: Character TYPE Header file. It contains various character testing and conversion function.)" file
Reply:#include %26lt;stdio.h%26gt;


#include %26lt;ctype.h%26gt;








int main( int argc, char** argv )


{


char someText[] = "SOME upper case letters.";


char *p;


int countUpperCaseLetters=0;





for( p=someText; *p; p++ )


{


if( isupper(*p) )


{


countUpperCaseLetters++;


}


}





printf( "There are %d upper case letters in this piece of text:\n%s",





countUpperCaseLetters, someText );





return 0;





}


No comments:

Post a Comment