Saturday 19 March 2016

WAP in C to convert a string from Upper case to Lower case using library functions

//WAP in C to convert a string from Upper case to Lower case

#include <stdio.h>
#include <ctype.h>
#include <conio.h>

void main()
{
      char string[100];
      int count=0, ch, i;

      clrscr(); // to clear the console screen

      printf("Enter a string\n");
      gets(string); //input string

      for(i=0;string[i]!='\0';i++)
      {
            count++;  //count the number of characters in the string
       }

      printf("The entered string is : %s",string); //printing the entered string

       printf("\nLowerCase string is: ");
     
      for(i=0; i < count; i++)
      {
            ch = tolower(string[i]); //changing upper case character to lower case
            printf("%c",ch);
       }

      getch(); // for holding the console screen
}

No comments:

Post a Comment