modifying the code

Hello all!! i need help modifying this code to print out these exact outputs using nested loops.
i = 1 j = 2
i = 1 j = 3
i = 1 j = 4
i = 2 j = 3
i = 2 j = 4
i = 3 j = 4

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;
int main()
{
int i.j;
for(i = 1; i <=5; i++)
{
cout << "\n i is now" << i << endl;
for (j = 1; j <=4: j++)
cout << "j =" <<j;
}
return 0;
}

Last edited on
closed account (iN6fizwU)
Line 5 needs a comma, not a period.
Line 8 is redundant as your i value is output at the same time as j.
Consider the range of your i loop: it isn't 1 to 5 as you have coded.
Consider the range of your j loop: it isn't 1 to 4 (but it does depend on i).
Topic archived. No new replies allowed.