Nested loop

Write a program using nested loops that asks the user to enter a value for the number of rows to display. It should then display that many rows of asterisks, with one asterisk in the first row, two in the second row, and so on. For each row, the asterisks are preceded by the number of periods needed to make all the rows display a total number of characters equal to the number of rows.

A sample run would look like this:
Enter number of rows: 5
....*
...**
..***
.****
*****
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #include <iostream>
#include <string>
using namespace std;

int main()
{

int rows;
cout<< "Enter the number of rows: ";
cin>>rows;
for(int i=1;i<rows;i++){
    cout<<".";



}

}

I am stumped, I began to write a second for loop, thinking that was the way to go, but as I continued on my attempts, I realized I had no clue on how to write this one.
Last edited on
Topic archived. No new replies allowed.