#include <iostream>
using namespace std;
void main()
{
int i, j;
char alph = 'A';
int n,blk;
int ctr = 1;
cout<<"Input the number of Letters (less than 26) in the Pyramid : ";
cin>>n;
Write a C Program to display the pattern like pyramid using the alphabet.
for (i = 1; i <= n; i++)
{
for(blk=1;blk<=n-i;blk++)
cout<<" ";
for (j = 0; j <= (ctr / 2); j++) {
cout<<" "<< alph++;
}
alph = alph - 2;
for (j = 0; j < (ctr / 2); j++) {
cout<<" "<< alph--;
}
ctr = ctr + 2;
alph = 'A';
cout<<endl;
}
system ("pause");
}
using namespace std;
void main()
{
int i, j;
char alph = 'A';
int n,blk;
int ctr = 1;
cout<<"Input the number of Letters (less than 26) in the Pyramid : ";
cin>>n;
Write a C Program to display the pattern like pyramid using the alphabet.
for (i = 1; i <= n; i++)
{
for(blk=1;blk<=n-i;blk++)
cout<<" ";
for (j = 0; j <= (ctr / 2); j++) {
cout<<" "<< alph++;
}
alph = alph - 2;
for (j = 0; j < (ctr / 2); j++) {
cout<<" "<< alph--;
}
ctr = ctr + 2;
alph = 'A';
cout<<endl;
}
system ("pause");
}
Output:
A
A B A
A B C B A
A B C D C B A
Write a C++ Program to display the pattern like pyramid using the alphabet.
Reviewed by Unknown
on
May 30, 2017
Rating:
No comments: