What is wrong with the following while loop? While (sum <= 1000) sum = sum + 30;
举一反三
- 用循环结构编写计算sum=2+4+6+……+1000的程序。main( ){inti,sum;sum=0; ————;while(————){——————;i = i + 2;}printf(“sum=%d",sum);}
- 下列VBA程序段的执行结果为 。 I = 1 Do While I<=10 SUM = SUM + I I = I + 1 Loop Debug.Print SUM
- 将下面的for循环转换为while循环,补全代码。 long sum=0; for(inti=0;i<=100;i++) sum=sum+i; System.out.println("sum="+sum); 改写成: long sum=0; ① ; while( ② ){ sum=sum+i; ③ ; } System.out.println("sum="+sum);
- 以下程序段的执行结果是______。 int s=0,i=1; do { S+=i++; } while(i<=10); Console.WriteLine("sum={0}",sum); A: sum=54 B: sum=1 C: sum=55 D: sum=30
- 执行循环后,两变量 I, Sum 分别是: Dim I As Short = 1 Dim Sum As Long = 0 Do While I <= 5 Sum += I I = I + 2 Loop