0

Here's my code for the upright triangle. Now I'm hard up on doing the code for inverted triangle, I'm working on it right now, but a little help would be great.

#include <iostream.h>
#include <conio.h>
void main()
{
	int len,ht,ch,cho,sz,col=20,ctr=1;
	cout<<"\nTRIANGLE";
	cout<<"\nEnter Size: ";
	cin>>sz;
	if (sz<5||sz>20)
		cout<<"Size must be between 5 and 20 only.";
	else
	{
		clrscr();
		for(int x=1;x<=sz;x++,col--,ctr+=2)
		{
			gotoxy(col,x);
			for(int y=1;y<=ctr;y++)
			{
				cout<<"*";
			}
		}
	}
}
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by pamelaanne05
0
#include <iostream.h>
#include <conio.h>
void main()
{
	int len,ht,ch,cho,sz,col=10,ctr=1;

		cout<<"\nTRIANGLE";
		cout<<"\nEnter Size: ";
		cin>>sz;
		if (sz<5||sz>20)
			cout<<"Size must be between 5 and 20 only.";
		else
		{
		clrscr();
		for(int x=10;x>=sz;x--,col--,ctr+=2)
		{
			gotoxy(col,x);
			for(int y=1;y<=ctr;y++)
			{
				cout<<"*";
			}
		}
		}
	}

Here's an almost correct code for the inverted triangle, but the size is all messed up. D:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.