for loop triangles

Hello There, So i did the output below(code). And I wanted it to reverse like this:
____*
___**
__***
_****

Can somebody give me a clue of what to do? What I'm doing wrong
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  #include <iostream>
using namespace std;

int main ()
{
	for (int x=1; x<=5; x++)
	{
		for (int y=1; y<=x; y++)
		{
			cout << "*";
		}
		cout << endl;
	}
	system ("pause");
	return 0;
}


I've got a lot more questions but I'm stuck in this one.
closed account (28poGNh0)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# include <iostream>
using namespace std;

int main()
{
	for(int x=1; x<=5; x++)
	{
		for(int y=5; y>=1; y--)
		{
		    if(y<=x)
                cout << "*";
            else cout << "_";
		}
		cout << endl;
	}

	return 0;
}


Maybe this new version will works
Last edited on
The answer depends on purpose.

If the purpose is to learn basic programming constructs and logic, then you do use the low level stuff, as in the code examples above.

If the purpose is to use C++, then read the reference documentation about io manipulators.
For example: http://www.cplusplus.com/reference/iomanip/setfill/
I'm learning basic programming. Thanks for the help. I appreciate it.
Topic archived. No new replies allowed.