How many times will the loop body be executed? int k=0; while(k=1)k++;
举一反三
- How many times is the loop body " k++;"<br/>executed in the following program segment? ( )<br/>int k=0; while(k=1)<br/>k++; A: Infinite B: 1 C: 0 D: compile error
- If k is integer, how many times will the following "while" loop be executed?k = 50 while k >; 1: print(k) k = k // 2 A: 3 B: 4 C: 5 D: 6
- 以下能够实现计算5!的程序段是( ) A: int fac=1,k=0;do{ k++; fac*=k;} while(k<;5); B: int fac=0,k=1;do{ fac*=k; k++;} while(k<;5); C: int fac=1,k=1;do{ k++; fac*=k;} while(k<;=5); D: int fac=1,k=0;do{ fac*=k; k++;} while(k<;5);
- int k=0; while(k<10) { if(k<1) continue; if(k==5) break; k++; }
- How many times will the following while loop execute? [br][/br]k = 50 [br][/br]while k > 1: [br][/br]print(k) [br][/br]k = k // 2 A: 5 B: 3 C: 4 D: 6