Write a C program to print the given alphabet pyramid.


A B C D E F G G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
-----------------------------------

#include
#include
int main( )
{
  int r,c,askey;
  clrscr( );
  
  for( r=7; r>=1; r-- )
  {
    askey=65;
    for(c=1; c<=r; c++ )
      printf("%2c", askey++ );
    askey--; 
    for(c=r; c>=1; c-- )
       printf("%2c", askey--);
   
   printf("\n");
  }
  getch();
  return 0;
}
 
Output:- 
A B C D E F G G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
Note:- 
'r' and 'c' means rows and columns .
'askey' variable is for disp. values.

V.P. Singh Rajput

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

7 comments:

  1. Here i am trying to solve a question. I want to make a program in C++ format(not in C format) which results in a PYRAMID OF ALPHABETS as shown below:
    A
    AB
    ABC
    ABCD
    ABCDE

    I have found a similar solution for this problem but that was in C language format not in C++ format. I will b thankfull to u if u provide me the solution in C++ format.

    ReplyDelete
  2. C PROGRAM TO PRINT ALPHABETS IN FOLLOWING FASHION

    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    BCDEFGHIJKLMNOPQRSTUVWXY
    CDEFGHIJKLMNOPQRSTUVWX
    DEFGHIJKLMNOPQRSTUVW
    EFGHIJKLMNOPQRSTUV
    FGHIJKLMNOPQRSTU
    GHIJKLMNOPQRST
    HIJKLMNOPQRS
    IJKLMNOPQR
    JKLMNOPQ

    ReplyDelete
  3. #include
    int main( )
    {
    int r,c,askey,j=0;


    for( r=j; r<=25;r++)
    {
    askey=65+r;
    for(c=r; c<=25; c++ )
    printf("%2c", askey++ );


    printf("\n");


    }

    return 0;
    }

    ReplyDelete
  4. A
    A A
    A A A
    A A

    CODE NEEDED...PLZ HELP

    ReplyDelete
  5. to print any size of pattern of "A"

    ReplyDelete
  6. A
    ABA
    ABCBA
    ABCDCBA

    give the code for this

    ReplyDelete
  7. A B C D E F G G F E D C B A
    A B C D E F F E D C B A
    A B C D E E D C B A
    A B C D D C B A
    A B C C B A
    A B B A
    A A

    #include
    using namespace std;
    main()
    {
    int no=65;
    for(int row=71;row>=no;row--)
    {
    for(int a=65;a<=row;a++)
    cout<<(char) a<<" ";

    for(int b=row;b>=65;b--)
    cout<<(char) b<<" ";

    cout<<endl;
    }
    }

    ReplyDelete