Tuesday 18 September 2012

String017

Write a program to construct  the image shown below.

                      I    I    I    I    I
                        N  N  N  N
                           D   D  D
                               I    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 = ln; i > j; i-- )
                       {                              
                                     printf("%c ", nm[ j] );
                       }
                       a++;
                       printf("\n\n" );
          }
          getch ( );
}
 Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...