Goals: Developing problem-solving skills, using nested loops
Problem: You are to create a program that will ask the user to enter a number, then uses a nested for loop that will produce output similar to that shown below.
User entered 5 User entered 6 User entered 8 User entered 4
5***** 6****** 8******** 4****
4**** 5***** 7******* 3***
3*** 4**** 6****** 2**
2** 3*** 5***** 1*
1* 2** 4****
1* 3***
2**
1*
Your program should confirm that the user enters a positive number. Aside from the validation, your program should only contain 4 cout statements: one that asks the user for a positive integer, one that displays the numbers, one that displays a single asterisk, and one that will change lines.
My question is: How do I make columns? I'm kind of lost here.
Here's my code so far:
#include <iostream>
using namespace std;
int main()
{
int sum;
cout << " Enter a value \n" << endl;
cin >> sum;
for(int i = sum; i > 0; i = i - 1){
cout << i << endl;
for(int i = sum;)
}
}