Tuesday 18 September 2012

String016

Write a program to construct  the image shown below.
                         I
                         N N
                         D D D
                         I   I   I   I
                         A  A  A  A  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[ j] );
                      }
                      printf("\n\n" );
          }
          getch ( );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...