Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;
   }

Print numbers 0 1, 2, userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly) Note: Avoid any other spaces like spaces after the printed number. Ex: userNum prints:

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;
}