I need help with the following question. Question Code: I can only edit the \"Yo
ID: 3850603 • Letter: I
Question
I need help with the following question.
Question
Code: I can only edit the "Your solution goes here"
#include
using namespace std;
int main() {
int userNum = 0;
int i = 0;
int j = 0;
/* Your solution goes here */
return 0;
}
Explanation / Answer
Here I have provided the answer , also commented the code for your understanding . the bold part is the one that is modified. to run this program you need to provide integer user input.
#include <iostream>
using namespace std;
int main()
{
int userNum = 0;
int i = 0;
int j = 0;
/* take input from user in userNum variable */
cin >> userNum;
/* Two for loops one for priting the variable number and other for printing the space into it */
for(i=0;i<=userNum;i++){
for(j=0;j<i;j++){
cout << " ";
}
cout << i << " ";
}
return 0;
}