Output

#include <iostream>
int main()
{

for( int=1; i<=6; i++) {
for ( int j=5; j>=1; j--)
cout<< i+j;
cout<< "\n";
}
return 0;
}


Can someone help me understand the output of these nested for loops and how to trace the output. Thank you.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

int main()
{
    for( int i = 1; i <= 6; ++i )
    {
        std::cout << "outer loop: i == " << i << '\n' ;
        for ( int j = 5; j >= 1; --j )
        {
            std::cout << "\tinner loop: j == " << j
                      << "    i+j == " << i + j << '\n' ;
        }
        std::cout << "\n";
    }
}

http://coliru.stacked-crooked.com/a/11463c4ce125fe07
Topic archived. No new replies allowed.