Wednesday 19 September 2012

String018

Input a sentence and print all the words of that sentence.

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

void main ( )
{
          char        nm[80];
          int           ln, j;
          clrscr ( );
                                
          printf("\n\n\n\t\t Enter a sentence....:"); gets (nm);
          for ( ln = 0; nm[ln] != '\0'; ln++ );
                                                 
          printf("\n\n\n\t\t WORDS....:     ");
          for ( j = 0; j < ln; j++ )
          {                                     
                      if ( nm[ j] == ' ' )
                      {                            
                                     printf("\n\n\t\t\t\t");
                      }               
                      else                               
                      {                                      
                                     printf("%c", nm[ j] );
                      }
          }
          getch ( );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...