Logo 
Search:

C Programming Articles

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

Program to print pyramid of abcd in reverse pattern

Posted By: Brett Smith     Category: C Programming     Views: 11341

WRITE A PROGRAM TO GENERATE FOLLOWING FIGURE OF N LINES. INPUT N FROM KEYBOARD.

____W
___W X
__W X Y
_W X Y Z
W X Y Z A

consider space in place of line.

Code for Program to print pyramid of abcd in reverse pattern 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 print pyramid of abcd in reverse pattern Or get search suggestion and latest updates.

Brett Smith
Brett Smith author of Program to print pyramid of abcd in reverse pattern is from Sydney, Australia.
 
View All Articles

 
Please enter your Comment

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

 
No Comment Found, Be the First to post comment!