Tuesday 21 August 2012

Loop control structure052

Write a program to construct  the image shown below.
                        1 1 1 1 1 1 1 1 1
                        1 0 0 0 0 0 0 1
                        1 0 0 0 0 0 1
                        1 0 0 0 0 1
                        1 0 0 0 1
                        1 0 0 1
                        1 0 1
                        1 1
                        1

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

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



Click here to contact us 

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...