Header Ads

Gate shape Using Alphabet

Write a program to create the following Pyramid using C program?
ABCDEFGFEDCBA
ABCDEF   FEDCBA
ABCDE        EDCBA
ABCD             DCBA
ABC                   CBA
AB                         BA
A                              A


*******************************Program*************************

#include<stdio.h>
#include<conio.h>
main()
{
 int i,j,m,k=0,l,p=0,o,a,b=0,c=0;
 m='G';
 o='F';
 for(j=1;j<=7;j++)       /*whole loop control */
 {
 for(i='A';i<=(m-k);i++)   /*printing first alphabet line*/
 {
  printf("%c",i);
 }
 for(a=1;a<b;a++){       /*providing spaces after first line*/
 printf(" ");
 }
 for(l=(o-p);l>='A';l--)         /*printing second alphabets line*/
 {
  printf("%c",l);
 }
 p=p+c;
 b=b+2;
 k=k+1;
 c=1;
 printf("\n");             /* giving line breaks */
    }
    getch();
}


*******************************Output**************************

screen shot for  pyramid shape using alphabet

No comments