Saturday, 5 April 2014

How to Convert an Upper Case String to a Lower Case?

To convert an upper case string to a lower case, I am using arrays along with for loop. This is an easy method you can do it very easily.

 

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
    clrscr();
    char mystring[30];
   int i;

   printf("\nEnter any String in UPPER Case:\n\n");
   scanf("%s",&mystring);

   printf("\nYour Entered String is: %s",mystring); 
   for(i=0;i<=strlen(mystring);i++)
   {
          if(mystring[i]>=97 && mystring[i]<=122)
          mystring[i]=mystring[i]+32;
   }
   printf("\nThe string in LOWER CASE ::\n%s",mystring);
   getch();
}

No comments:

Post a Comment