Develop a program in C++ to display the pattern like a pyramid using an asterisk * and each row contains an odd number of asterisks by using the 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 |
# include <iostream> using namespace std; class T4Tutorials { protected: int i,j; }; class pattern { protected: int s, rows; }; class show: public T4Tutorials, public pattern { public: int total() { cout<<"enter no of rows"; cin>>rows; for(i=1; i<=rows;i++) { for(s=i; s<rows; s++) { cout<<" "; } for(j=1; j<=2*i-1; j++) { cout<<"*"; } cout<<endl; } } }; int main() { show myobj; myobj. total(); } |
FAQ
Pattern programs in C++ using for loop and multiple inheritances in Object-Oriented Programming (OOP).
C++ pattern program examples by using the multiple inheritances in Object-Oriented Programming (OOP).
C++ program to print the pyramid by using the multiple inheritances in Object-Oriented Programming (OOP).
C++ program to print pyramid pattern of asterisks by using the multiple inheritances in Object-Oriented Programming (OOP).
Pattern program C++ Â by using the multiple inheritances in Object-Oriented Programming (OOP).
C++ Pattern Examples by using the multiple inheritances in Object-Oriented Programming (OOP).