Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 Point out the error, if any in the for loop. #include<stdio.h> int main() { int i=1; for(;;) { printf("%d\n", i++); if(i>10) break; } return 0; } ?->(Show Answer!)
1. Point out the error, if any in the for loop. #include<stdio.h> int main() { int i=1; for(;;) { printf("%d\n", i++); if(i>10) break; } return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.01 pm
Step 1: for(;;) this statement will genereate infinite loop.
Step 2: printf("%d\n", i++); this statement will print the value of variable i and increement i by 1(one).
Step 3: if(i>10) here, if the variable i value is greater than 10, then the for loop breaks.
Hence the output of the program is
1
2
3
4
5
6
7
8
9
10
Step 2: printf("%d\n", i++); this statement will print the value of variable i and increement i by 1(one).
Step 3: if(i>10) here, if the variable i value is greater than 10, then the for loop breaks.
Hence the output of the program is
1
2
3
4
5
6
7
8
9
10