How many times will the loop body be executed? int k=0; while(k=1)k++;
infinite
举一反三
- 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
内容
- 0
与下面代码片段等价的代码片段是 int k = 0; while (k++ A: int k; for (k = 0; k B: int k; for (k = 0; k C: int k; for (k = 0; k D: int k; for ( k = 1; k
- 1
假设有程序段:int k=0; while(k=1) k++; while语句的循环次数是
- 2
设有定义:int k=0;,则循环语句while(k=1)k++;的循环体_____
- 3
下面程序的循环次数是( )。 int k=0; while(k<10) { if(k<1) continue; if(k==5) break; k++; }
- 4
以下能正确计算1╳2╳3╳…╳10的程序段是( )。 A: do<br/>{ k=1;n=1;n=n*k;k++;}while(k B: do<br/>{ k=1;n=0;n=n*k;k++;}while(k C: k=1;n=1;do<br/>{ n=n*k;k++;}while(k D: k=1;n=0;do<br/>{ n=n*k;k++;}while(k