0

For loop

is it possible to write a for loop with a body that is never executed?

9th Nov 2016, 6:28 PM
Rabbi Sarpong
2 Antworten
+ 5
int main(){ int i = 5; for(; i<5;i++){ // some code here } return 0; } since i variable is initialized to 5 and 5 is not smaller than 5, the for loop will not be executed
9th Nov 2016, 7:15 PM
Burey
Burey - avatar
0
just put a semicolon after for loop. It will terminate your for loop there itself.
10th Nov 2016, 1:20 AM
kamal joshi
kamal joshi - avatar