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
举一反三
- 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