Write a C++ Program to display the pattern like a pyramid using the alphabet using Multiple inheritances.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#include<iostream> using namespace std; class one { protected: int i,k,n,bl,ct; }; class two { protected: char alp; }; class child:public one,public two { public: int pyr() { ct=1; alp='A'; cout<<"Input the number of letters(less than 26) in the pyramid :"; cin>>n; { for(i=1;i<=n;i++) { for(bl=1;bl<=(n-1);bl++) cout<<" "; for(k=0;k<=(ct/2);k++) { cout<<" "<<alp++; } alp=alp-2; for(k=0;k<(ct/2);k++) { cout<<" "<<alp--; } ct=ct+2; alp='A'; cout<<endl; } } } }; int main() { child c; c.pyr(); } |