0
Can someone explain nested loops ?
#include <iostream> using namespace std; int main() { for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 2; j++) { // code } } return 0; }
2 Respostas
+ 1
In this code, the for loop is inside another for loop. The nested for loop is executed 3 times, each time 2 times, for a total of 6 times. The other for loop is executed only 3 times. There are errors in your code. The correct syntax is i++, j++.
0
Thanks, now, i understand