Q:

Number based triangle using for loops

Can you help me write a program that reads the number of rows from the user and displays the shape of a number based triangle using only for loops. 
for example If R = 4 the output will be:
       1

     2 4 6

  3 6 9 12 15

4 8 12 16 20 24 28

I wrote the program, but I don't know how to make it look like a pyramid. Can someone help me with that?
And this is the program I wrote:
#include <iostream>
using namespace std;

int main ()
{
    int n, i, j;

    cout << "Please enter number of rows\n";
    cin >> n;
    for(i=1; i<=n; i++)
    {
        cout << endl;
        for (j=1; j<2*i; j++)
        {   
            cout <<" ";
            cout << i*j;
        }
    }
    return 0;
}

A:

You could use 2 for loops, you just have to understand the problem correctly then you could convert it to code easily.
from my understanding you want to have n rows and in ith row you want to have multiple of i with every number less than or equal 2*i-1 so just use one for to print out the new line and in every row print out that multiples.

