Site icon T4Tutorials.com

class objects C++ program to display pattern like the right angle

Write a program in C++ to make such a pattern like the right angle triangle with a number that will repeat a number in a row using the class objects in object-oriented programming.

pattern of right angle triangle C++

#include<iostream>
using namespace std;
class first
{
	protected :
		int i,j,n,r;
	public :
		int pat()
	{
		cout<<"Enter no of rows : ";
		cin>>n;
		for(i=1 ; i<=n ; i++)
		{
			for(j=1 ; j<=i ; j++)
			{
				cout<<i;
			}
			cout<<endl;
		}
	}
};
int main()
{
	first a;
	a.pat();
}

 

Exit mobile version