Wednesday 22 August 2012

Loop control structure062


Write a program to construct  the image shown below.
                                   1
                                 13 
                               135
                             1357
                           13579
                             1357
                               135
                                 13
                                   1

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

void main ( )
{
           int          i, j, s;
           clrscr ( );
                                     
           printf ("\n\t\t\t\t Design of Numbers");
           printf ("\n\n\n\n\n\n\n\t\t\t\t");
                                                      
           for ( i = 1; i <= 9; i = i + 2 )
           {                                         
                           for ( s = 9; s >= i; s = s - 2 )
                           {                                           
                                           printf ("  ");
                           }                        
                           for ( j = 1; j <= i; j = j + 2 )
                           {                                          
                                           printf("%d ", j);
                           }
                           printf ( "\n\n\t\t\t\t" );
           }                                                
                                  
           for ( i = 7; i >= 1; i = i - 2 )
           {                                          
                           for ( s = 9; s >= i; s = s - 2 )
                           {                                                    
                                           printf ("  ");
                           }                    
                           for ( j = 1; j <= i; j = j + 2 )
                           {                                   
                                           printf("%d ", j);
                           }
                           printf ( "\n\n\t\t\t\t" );
           }
           getch();
}



Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...