Wednesday 22 August 2012

Loop control structure063

Write a program to construct  the image shown below.
                ABCDEFEDCBA
                ABCDE  EDCBA
                ABCD       DCBA
                ABC            CBA
                AB                 BA
                A                      A

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

void main ( )
{
          int        i, j, k, s = -1;
          clrscr ( );
                                      
          printf ("\n\t\t\t\t Design of Alphabets");
          printf ("\n\n\n\n\n\n\t\t\t\t");
                                           
          for ( i = 'F'; i >= 'A'; i-- )
          {                                    
                           for ( j = 'A'; j <= i; j++ )
                           {                                    
                                             printf("%c ", j);
                           }                   
                           for ( k = 1; k <= s; k++ )
                           {                                     
                                            printf ("  ");
                           }                                     
                           s = s + 2;
                           if ( i == 'F' )
                                    j = i - 1;
                           else                        
                                    j = i;
                           for ( ; j >= 'A'; j-- )
                           {                              
                                             printf("%c ", 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...