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<<"*";
			}
		}
	}
}
#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:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.