Output of the following program ismain(){int i=0;for(i=0;i<20;i++){switch(i){case 0:i+=5;case 1:i+=2;case 5:i+=5;default:i+=4;break;}}}A. 5,9,13,17B. 12,17,22C. 16,21D. syntax error.
option:cfirst enter the loop with i value i=0,then enters switch statement.then case 0 is selected.theis break statement for case 0,so case1 also executed,same as for all casee,after default i becomes 16,goto for statement.condition is true,then select default case,just it is incremented by 4,then it becomes to 21.
Output of the following program ismain(){int i=0;for(i=0;i<20;i++){switch(i){case 0:i+=5;case 1:i+=2;case 5:i+=5;default:i+=4;break;}}}A. 5,9,13,17B. 12,17,22C. 16,21D. syntax error.
Related Answered Questions
Related Open Questions