I need help looping this code so that is prompts the user to enter a number of rows again how many times the user would like to continue, I suck at loops and I've tried looking at other forums for help and just get more confused.
//libraries
#include <iostream>
usingnamespace std;
//global constants
//no functioning prototype
int main(){
//Define variables
int n; // Number of rows
int i; // Row count in for loop
int k; // Output for loop
// Have user input n
cout << "Enter number of rows: ";
cin >> n;
// Complete for loop
for (i = 1; i <= n + 1; i++){
for (k = 1; k < i; k++){
if (k<i-1) cout << ' '; else cout << k <<endl;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
//libraries
#include <iostream>
usingnamespace std;
//global constants
//no functioning prototype
int main(){
//Define variables
int n; // Number of rows
int i; // Row count in for loop
int k; // Output for loop
do{
// Have user input n
cout << "Enter number of rows: ";
cin >> n;
// Complete for loop
for (i = 1; i <= n + 1; i++){
for (k = 1; k < i; k++){
if (k<i-1) cout << ' '; else cout << k <<endl;
}
}
}while(n!=0);
system("PAUSE");
return EXIT_SUCCESS;
}