Wednesday 22 August 2012

Loop control structure060

Write a program to construct  the image shown below.
                                                *
                                               **
                                              ***
                                            *****
                                          *******
                                        *********
                                      ***********
                                    *************
                                  ***************
                                *****************
                                  ***************
                                    *************
                                      ***********
                                        *********
                                          *******
                                            *****
                                              ***
                                               **
                                                *


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

void main ( )
{
            int          i, j, k;
            clrscr ( );
                                   
            printf ("\n\t\t\t   Design of stars");
            printf ("\n\n\n");
                                       
            for ( i = 1; i <= 9; i++ )
            {                                     
                            for ( k = 35; k >= i; k-- )
                            {                                      
                                               printf (" ");
                            }                                         
                            for ( j = 1; j <= 2 * i - 1; j++)
                            {                                                
                                               printf ("*");
                            }                                      
                             printf ("\n");                  
            }                                                                       
            for ( i = 8; i >= 1; i-- )
            {                                                                      
                            for ( k = 35; k >= i; k-- )
                            {                                                       
                                               printf (" ");
                            }                                                              
                            for ( j = 1; j <= 2 * i - 1; j++)
                            {                                            
                                               printf ("*");
                            }
                            printf ("\n");
            }
            getch ( );
}



Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...