Monday 17 September 2012

String014

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;
        clrscr ( );
             
        printf("\n\n\n\t\t Enter a word....:"); gets (nm);
        for ( ln = 0; nm[ln] != '\0'; ln++ );
              
        printf("\n\n\n\n\n\t\t\t" );
        for ( j = 0; j < ln; j++ )
        {                                      
                    for ( i = 0; i <= j; i++ )
                    {                                   
                                printf("%c ", nm[i] );
                    }
                    printf("\n\n\n\t\t\t" );
        }
        getch ( );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...