Home / C Programs / C program to print reverse pyramid of alphabets

C program to print reverse pyramid of alphabets

C program to print reverse pyramid of alphabets :  In my previous two programs, we have seen that how to create pyramid using stars and pyramid using numbers (also called Pascal’s triangle). Now, we will learn how to extend that logic to make a reverse pyramid of alphabets. Logic will be somewhat similar to previous two programs but we need to include default value of alphabets using ASCII conversion format and then use those in our logic. This takes number of rows from user as its input and then displays a cool reverse pyramid made up of alphabets.

Let us see how to write a C program to print reverse pyramid of alphabets that takes number of rows in pyramid as user input and displays reverse alphabetical pyramid.

C program to print reverse pyramid of alphabets :

#include<stdio.h>
#include<conio.h>
int main( )
{
  int r,c,askey,sp,num;
  printf("------------------------------------------------------------------\n");
  printf("-------------------made by C code champ --------------------------\n");
  printf("------------------------------------------------------------------\n");
  printf("\n\n\tC PROGRAM TO PRINT REVERSE PYRAMID OF ALPHABETS \n");  
  printf("\nEnter the number of rows you want to show in your reverse pyramid : ");
  scanf("%d",&num);
  printf("\n\n\n");
  for( r=num; r>=1; r-- )
  {
    printf("\t");
    for(sp=num-1; sp>=r; sp--)
        printf("  "); //2 spaces

    askey=65;
    for(c=1; c<=r; c++ )
      printf("%2c", askey++ );
    --askey;
    for(c=r-1; c>=1; c-- )
       printf("%2c", --askey);

   printf("\n");
  }
  getch();
}

We hope that you all have enjoyed of alphabets in . If you have any queries or issues regarding above code or logic ask us in form of comments.

About Mr Coder

Well, I am software programmer and love to code. My hobbies is to do Hacking, Coding, Blogging, Web Designing and playing online games. Feel free to contact me at shiviskingg@gmail.com or lokesh@hackingloops.com

Check Also

C Program to Implement Stack

This C Program implements stack. Stack is an area of memory that holds all local …

Leave a Reply

Your email address will not be published. Required fields are marked *