Advertisement
mhrabbi

P10.WAP to convert a given string into sentences case

Jul 26th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     char str[200];
  5.     int i;
  6.  
  7.  
  8.     printf("Enter a string: ");
  9.     gets(str);
  10.  
  11.     for(i=0; str[i]!='\0'; i++)
  12.     {
  13.  
  14.         if(i==0)
  15.         {
  16.             if((str[i]>='a' && str[i]<='z'))
  17.                 str[i]=str[i]-32;
  18.             continue;
  19.         }
  20.         if(str[i]==' ')
  21.         {
  22.  
  23.             ++i;
  24.  
  25.             if(str[i]>='a' && str[i]<='z')
  26.             {
  27.                 str[i]=str[i]-32;
  28.                 continue;
  29.             }
  30.         }
  31.         else
  32.         {
  33.  
  34.             if(str[i]>='A' && str[i]<='Z')
  35.                 str[i]=str[i]+32;
  36.         }
  37.     }
  38.  
  39.     printf("Capitalize string is: %s\n",str);
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement