• 2022-06-09
    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
  • A

    内容

    • 0

      下面哪一个循环会导致死循环____。 A: for(int<br/>k=0;k B: for(int<br/>k=10;k&gt;0;k--) C: for(int<br/>k=0;k D: for(int<br/>k=0;k&gt;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 &quot;while&quot; loop be executed?k = 50 while k &gt; 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);