C strupr

strupr() is one of the inbuilt string function in c programming which is used to converts the lowercase characters to UPPERCASED characters.

Syntax - strupr()
  • strupr() accepts one parameter.
  • Parameter must be a string.
  • To use strupr() inbuilt string function in C, we need to declare #include<string.h> header file.

 Example

#include <stdio.h>
#include<string.h>
int main()
{
char str[100];
   
   printf("\nEnter the String : ");
   gets(str);
printf(" Output of given string is %s ", strupr(str));
return 0;

Output

 

 

Without using stupr library function 

#include <stdio.h>
#include<string.h>
int main()
{
char str[100],i;
   printf("\nEnter the strings :");
   gets(str);
   for(i=0; str[i]!='\0';i++)
{
if(str[i]!=32){
// filtering blank space
printf(" %c",str[i]-32);
}
else
printf(" ");
}
return 0;

Output

No comments:

Post a Comment