I'm supposed to print off stars. I prompt the user for a number (we'll call it n), and then print out n lines of stars. The first line will have one star and then it adds one each line.
eg.
Enter the number of lines -> 5
*
**
***
****
*****
I have this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main() {
int n;
cout << "Enter the number of lines." << endl;
while (cin >> n) {
//--- Loop counting i up from 1 to n.
int i = 1; // Initialize counter.
while (i <= n) { // Test counter.
cout << "*";
i++; // Increment counter.
}
cout << endl;
}
return 0;
}
That gives me the entered number of stars but I don't know how to get the lines of stars up to that point.
eg. If I run it now:
Enter number of lines -> 5
*****