Multiple inheritances C++ program to print hollow rhombus, parallelogram star pattern
Develop a C++ program to print a hollow rhombus star series pattern using for loop and Multiple inheritances.
How to print hollow rhombus or parallelogram star pattern in C++ programming using Multiple inheritances in OOP. The Logic to print empty rhombus or parallelogram star pattern series in C++ programming 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 49 50 |
#include<iostream> using namespace std; class A { public: int r; }; class B { public: int sp; }; class C:public A, public B { public: void disp() { for(r=1;r<=4;r++) //loop for displaying the number of rows { for(sp=r;sp<4;sp++) //loop for printing the spaces in first row { cout<<" "; } if(r==1||r==4)
//condition for first or last row { for(sp=1;sp<=4;sp++) //loop for printing stars in first and last row if above condition is true { cout<<"*"; } } else //print firstly 1 star then 2 spaces and then one star if "if condition" is false { cout<<"*"; for(sp=1;sp<=2;sp++) { cout<<" "; } cout<<"*"; } cout<<endl; } } }; int main() { C T4Tutorials; //create the object of class T4Tutorials.disp(); // call function by object } |
Output