Site icon T4Tutorials.com

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.

#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

C++ program to print rhombus star pattern of Number of rows using constructor overloading

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.

Exit mobile version