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

12th Jul 2025, 3:48 PM
🏳️‍⚧️👑 Queen Chanel
🏳️‍⚧️👑 Queen Chanel - avatar
2 Réponses
+ 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++.
12th Jul 2025, 4:02 PM
Mila
Mila - avatar
0
Thanks, now, i understand
12th Jul 2025, 4:23 PM
🏳️‍⚧️👑 Queen Chanel
🏳️‍⚧️👑 Queen Chanel - avatar