Saturday 15 September 2012

String010

Input a word. If the word is in small later convert it into capital later or if the word is in capital later convert it into small later.

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

void main ( )
{
         char      nm[80], ch;
         int         i, ln;
         clrscr ( );
                 
         printf("\n\n\n\t\t Enter a word....:"); gets (nm);
         for ( ln = 0; nm[ln] != '\0'; ln++ );
           
         for ( i = 0; i < ln; i++ )
         {                          
                      ch = nm[i];
                      if ( ch >= 65 && ch <= 90 )
                      {                               
                                     nm[i] = nm[i] + 32;
                      }               
                      if ( ch >= 97 && ch <= 122 )
                      {                      
                                     nm[i] = nm[i] - 32;
                      }
         }   
                 
         printf("\n\n\n\t\t WORD...: %s ", nm);
         getch ( );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...