Display a pattern using loops

I have spent at least an hour trying to display this pattern and I am not getting anywhere.

Pattern C
1
21
321
4321
54321
654321


This is as far as I got
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
cout << "Pattern C" << endl;
// Enter an initial value for i
for (int i = 1; i <= 6; i++)
{
// Increment the value of J
for (int j = 1; j <= i ; j++)
{
cout << setw (2)<< i;

}

cout << endl;

}

return 0;
}

/* Pattern C
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
Program ended with exit code: 0 */
1
2
3
4
for (int j = 1; j <= i ; j++)
{
cout << setw (2)<< i;
//                 ↑ Use j instead 
J instead of I gives me this

Pattern C
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
How can you get the numbers you want using the i and j values?
Do the loop backward:
for (int j = i; j > 0 ; --j)
Topic archived. No new replies allowed.