How many times is the loop body " k++;"
executed in the following program segment? ( )
int k=0; while(k=1)
k++;
A: Infinite
B: 1
C: 0
D: compile error
executed in the following program segment? ( )
int k=0; while(k=1)
k++;
A: Infinite
B: 1
C: 0
D: compile error
A
举一反三
- How many times will the loop body be executed? int k=0; while(k=1)k++;
- 以下能正确计算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
- 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
- 以下能够实现计算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);
- 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
内容
- 0
下面哪一个循环会导致死循环____。 A: for(int<br/>k=0;k B: for(int<br/>k=10;k>0;k--) C: for(int<br/>k=0;k D: for(int<br/>k=0;k>0;k++)
- 1
int k=0; while(k<10) { if(k<1) continue; if(k==5) break; k++; }
- 2
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
- 3
有以下程序段[br][/br]Int k=0;[br][/br]While(k=1)k++;[br][/br]while循环执行的次数为() A: 1次 B: 2次 C: 无限次 D: 0次
- 4
以下能正确计算1╳2╳3╳...╳10的程序段是( A: do{k=1;n=1;n=n*k;k++;}while(k<=10); B: do{k=1;n=0;n=n*k;k++;}while(k<=10); C: k=1;n=1;do{n=n*k;k++;}while(k<=10); D: k=1;n=0;do{n=n*k;k++;}while(k<=10);