C++ program of friend function to print rhombus star pattern
Write a C++ program to print rhombus star pattern of Number of rows using friend function.
C++ program to print rhombus star pattern of Number of rows using friend function.
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 |
#include<iostream> using namespace std; class T4Tutorials { protected : int i,j,k,n; public : fun() { cout<<"Enter Number of rows : "; cin>>n; } friend int show(T4Tutorials); }; int show(T4Tutorials a) { for(a.i=1 ; a.i<=a.n ; a.i++) { for(a.k=
1 ;a.k<=a.n-a.i; a.k++) { cout<<" "; } for(a.j=1 ; a.j<=a.n ; a.j++) { cout<<"*"; } cout<<endl; } } int main() { T4Tutorials a; a.fun(); show(a); } |
Output
How to print rhombus or parallelogram star pattern using friend function in C++ programming.
The Logic to print rhombus or parallelogram star pattern series in C++Â using friend function.