Showing posts with label convert string lower to uppercase letter cporgram. Show all posts
Showing posts with label convert string lower to uppercase letter cporgram. Show all posts

Saturday, December 24, 2011

Convert string UpperCase

Q. Write a string to accept string through keyboard and convert it Uppercase letter.

Ans.

/*program to convert a string in upper case letter*/
#include<stdio.h>
#include<string.h>
int main()
{
 char str[40];
 int i;
 printf("Enter any string : ");
 gets(str);
 for(i=0; str[i]!=NULL; i++)
 {
   if(str[i]>='a' && str[i]<='z')
   {
      str[i]=str[i]-32;
   }
 }
 str[i]='\0';
 puts(str);
 getch();
 return 0;
}

Output:-

Enter any string : My C ProgrammING CodeS
MY C PROGRAMMING CODES