Using loops

I have been stuck on this problem for hours, does anyone have any insight as to how to do this.

Write a C++ program to print the following output.

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

You can use nested 2 loops, one is to print all the columns of a row, the one outside of it will print all rows.
1
2
3
4
5
6
7
8
for (int i = 1;i < 5;++i)
{
  for(int j = 1; j < i; ++j)
  {
    std:: cout << i;
  }
  std::cout << std::endl ;
}


Maybe some values need to be fixed but basically this should make it.
Topic archived. No new replies allowed.