C Program to Print the Double Pyramid Pattern | creating double Pyramid in C

C Program to Print the Double Pyramid Pattern | creating double Pyramid in C | C assignment to create double Pyramid of Alphabets in C



#include
#include

void main()
{
int i,j,k;
int blank=0;
int lines = 6;
char symbol='A';
int temp ;
int diff[7]= {0,1,3,5,7,9,11};
clrscr();
k=0;
//Step 0

    for(i=lines;i>=0;i--)
    {
       printf("\n");
       symbol = 'A';

       for(j=i;j>=0;j--)    //step 1
            printf("%c ",symbol++);

       blank = diff[k++];   //step 2

       for(j=0;j<blank;j++)
            printf(" ");    //step 3


       symbol = 'F' - (blank/2);

       if (blank== 0)
           temp = i-1;
       else
           temp = i;

       for(j=0;j<=temp;j++)  //step 4
           printf("%c ",symbol--);

    }
getch();
}



No comments:

Post a Comment