Multilevel inheritance C++ program to display pyramid pattern using the class objects
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 Multilevel inheritance.
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 | # include<iostream> using namespace std; class T4Tutorials { protected: int i,j; }; class child1: public T4Tutorials { protected: int s,rows; }; class child2: public child1 { public: int pattern() { 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<<"\n"; } } }; int main() { child2 myobj; myobj. pattern(); } |
FAQ
Pattern programs in C++ using for loop and Multilevel inheritance in Object-Oriented Programming (OOP).
C++ pattern program examples Multi-level inheritance in Object-Oriented Programming (OOP).
C++ program to print the pyramid Multi-level inheritance in Object-Oriented Programming (OOP).
C++ program to print pyramid pattern of asterisks Multi-level inheritance in Object-Oriented Programming (OOP).
Pattern program C++ Multilevel inheritance in Object-Oriented Programming (OOP).
C++ Pattern Examples Multi-level inheritance in Object-Oriented Programming (OOP).