Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to generate pyramid of ABCD from Z to A

Posted By: Hedwig Miller     Category: C Programming     Views: 6586

Program to generate pyramid of ABCD from Z to A

Code for Program to generate pyramid of ABCD from Z to A in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,n,j;
    char ch;
    clrscr();
    printf("\n Please Give The Value of N:  ");
    scanf("%d",&n);
    if(n>20)
    {
        printf("\n N MUST BE LESS THAN OR EQUAL TO 20 ");
        printf("\n OTHERWISE IT IS NOT DISPLAY AS PYRAMID");
        printf(" OR NOT FIT IN ");
    }
    else
    {
    for(i=1;i<=n;i++)
    {
        if(ch==90)
            ch=65;
        for(j=1;j<=n-i;j++)
            printf("  ");
        for(j=1,ch=87;j<=i;j++,ch++)
        {
        if(ch==91)
            ch=65;
            printf(" %c  ",ch);
        }
            printf("\n");


    }
    }
    getch();
}


--------------------------------- OUTPUT ---------------------------------




 Please Give The Value of N:  9


                 W
               W   X
             W   X   Y
           W   X   Y   Z
         W   X   Y   Z   A
       W   X   Y   Z   A   B
     W   X   Y   Z   A   B   C
   W   X   Y   Z   A   B   C   D
 W   X   Y   Z   A   B   C   D   E



--------------------------------------------------------------------------
  
Share: 


Didn't find what you were looking for? Find more on Program to generate pyramid of ABCD from Z to A Or get search suggestion and latest updates.

Hedwig Miller
Hedwig Miller author of Program to generate pyramid of ABCD from Z to A is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Md Meraj from India Comment on: Jan 05
wat is the logic behind

1
1 1
1 2 1
1 3 3 1

Md Meraj from India Comment on: Jan 05
1
232
34545
4567654
567898765
67890109876
7890123210987
890123454321098
90123456765432109
0123456789876543210

Md Meraj from India Comment on: Jan 05
1
01
101
0101
10101
how to write program

View All Comments