Tuesday 21 August 2012

Loop control structure056

Write a program to construct  the image shown below.
                                1
                              11
                            101
                          1001
                        10001
                      100001
                    1000001
                  10000001
                  111111111


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

void main ( )
{
           int            i, j, k;
           clrscr ( );
                                         
           printf ("\n\t\t\t   Design of Numbers");
           printf ("\n\n\n");
                                     
           for ( i = 1; i <= 9; i++ )
           {                                  
                           for ( k = 21; k >= i; k-- )
                           {                                        
                                              printf ("  ");
                           }                                     
                           for ( j = 1; j <= i; j++)
                           {                                    
                                           if ( i == 9 || j == 1 || j == i )
                                                            printf (" 1");
                                           else                                   
                                                            printf (" 0");
                           }
                           printf ("\n");
           }
           getch ( );
}



Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...