Monday 17 September 2012

String015

Write a program to construct  the image shown below. 
                         I
                       I  N
                     I  N  D
                   I  N  D  I
                 I  N  D  I  A
 
#include <stdio.h>
#include <conio.h>

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

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...