0

Can any one explain this code. Please. Why output is 1,2,4

#include <iostream> using namespace std; int main() { for (int i=1;i<5;i++){ if(i==3) continue ; cout <<i <<","; } }

19th Dec 2016, 4:17 AM
Aman Khan
Aman Khan - avatar
2 Réponses
0
when i is 3, continue takes you through the loop again, skipping the cout statement. So you get just 1,2, and 4.
19th Dec 2016, 4:34 AM
scott johnson
scott johnson - avatar
0
Scott, if there are many nested if inside this, how does it identify the end of loop?
19th Dec 2016, 5:02 AM
Doni
Doni - avatar