Sunday, February 14, 2021

Program to print half pyramid using alphabet using C++

Program to print half pyramid using alphabet using C++


#include<iostream.h>
#include<conio.h>
int main()
{
   char input;
   alphabet='A';
   cout<<"Enter the uppercase character you want 40 print the last row :";
   cin>>input;
   for(int i=1; i<=(input - 'A' + 1); ++i)
   {
      for(int j=1; j<=i; ++j)
      {
        cout<<alphabet<<" ";
      }
      ++alphabet;
      cout<<endl;
   }
   getch();
}


Output : 


Enter the uppercase character you want 40 print the last row :
C
A
B B
C C C

No comments:

Post a Comment