Triangle Pattern Side by Side

Good evening,

I've been asked to write a program for my intro to C++ class using loops that displays a triangle pattern side by side. I was able to write a code that will display the triangles, but I can't figure out how to make it side by side. Do I have to use some form of cout.width() to make them side by side?
Here's my code if anyone can help.
Thanks in advance!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
using namespace std;

int main()
{

	cout << "Pattern A \n";
	
	for(int x=0; x<=10; x++)
	{
		for(int y=0; y<x; y++)
		{
			cout<< "+";
		}
		cout<< "\n";
	}

	cout<< "\nPattern B\n\n";
	
	for(int x=10; x>=1; x--)
	{
		for(int y=0; y<x; y++)
		{
			cout << "+";

		}
		cout << "\n";
	}

	system("pause");

	return 0;
}
Last edited on
Topic archived. No new replies allowed.