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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int main()
{
    int i, j;
    for(i = 1; i < 4; i++)
    {
        for (j = i + 1; j < 5; j++)
        cout << "i = " << i  << " j = " << j << endl;
    }
    return 0;
}
i = 1 j = 2 
i = 1 j = 3 
i = 1 j = 4 
i = 2 j = 3 
i = 2 j = 4 
i = 3 j = 4


http://cpp.sh/93lc
Last edited on
Topic archived. No new replies allowed.