Saturday, December 24, 2011

Convert string LowerCase

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

Ans.

/*program to convert a string in lower 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

No comments:

Post a Comment