Triangle with Symbol | Pattern | Programming in C++

Draw a triangle with a symbol of a given height.

Code in C++

#include<iostream.h>
#include<conio.h>

void main()
{
	int r, c, h;
	clrscr();
	cout << "\n Enter the height: ";
	cin >> h;
	clrscr();

	for(r=1;r<=h;r++)
	{
		for(c=h-r+1;c<=h;c++)
		{
			gotoxy(c, r);
			cout << "*";
		}
	}
	getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *