【多选题】【消耗次数:1】
利用循环求1到5的和值,已知i=1,sum=0;利用循环每次让sum求和,然后i++;判断条件是i<6;则求和的循环操作是()。
sum=sum+i
sum+=i
sum=i
i=sum+i
参考答案:
复制
纠错
相关题目
【单选题】 在JavaScript中,运行下面的代码,sum的值是( )。 var sum = 0; for(i = 1; i < 10; i++) { if(i%5==0) break; sum = sum + i; }
①  40
②  50
③  5
④  10
【单选题】 在JavaScript中,运行下面的代码,sum的值是( )。var sum = 0;for(i = 1; i ( 10; i++) { if(i%5==0) break; sum = sum + i;}(选择一项)
①  40
②  50
③  5
④  10
【简答题】 以下程序输出结果是[填空1]。#include stdio.hvoid main(){ int i, sum=0;for(i=1; i i++)sum+=i;printf(″%d\n″,sum);}
【简答题】 以下程序输出结果是[填空1]。#include stdio.hvoid main(){ int i, sum=0;for(i=1; i i++)sum+=i;printf(″%d\n″,sum);}
【简答题】 以下程序输出结果是[填空1]。#include stdio.hvoid main(){ int i, sum=0;for(i=1; i i++)sum+=i;printf(″%d\n″,sum);}
【单选题】 以下程序执行后sum的值是( )。 main() { int i,sum; for(i=1;ii++) sum+=i; printf(%d\n,sum); }
①  15
②  14
③  不确定
④  0
【单选题】 下面程序执行后的结果是() #include stdio.h void fun( ) { int i,sum=0; int a[5]={1,2,3,4,5}; for (i=0;i { if (a[i]%2==0) { sum+=a[i]; } } printf(%d,sum); } void main( ) { fun( ); }
①  6
②  15
③  9
④  11
【单选题】 有如下程序 main() { int i,sum=2; for(i=1;ii+=2) sum+=i; printf(“%d\n”,sum); } 该程序的执行结果是( )
①  6
②  3
③  死循环
④  4
【单选题】 有以下程序,程序执行后的输出结果是( ) #include int fun(int x [ ],int n) { static int sum=0,i; for(i=0; i{ sum+=x[i]; } return sum; } void main( ) { int a[ ]={1,2,3,4,5}; int b[ ]={6,7,8,9},s=0; s=fun(a,5)+fun(b,4); printf(%d\n,s); }
①  45
②  50
③  60
④  66
【单选题】 若有定义int i=1;则执行完循环while(i++〈5);以后i 的值为()
①  6
②  5
③  4
④  7
随机题目
【单选题】 He wished to earn a living through writing but ( ) doing so.
①  succeeded in
②  was proud of
③  despaired of
④  was pleased with
【单选题】 Prices of goods ( ) online can be lower than those in off-line stores.
①  buying
②  buy
③  bought
④  that buys
【单选题】 The Chinese ( ) paper for two thousand years.
①  have made
②  have been making
③  had made
④  are being made
【单选题】 The windows were ( ) with locks and bars.
①  sought
②  surrendered
③  secured
④  separated
【单选题】 This job is great ( ) advancement, but its too far away from my hometown.
①  in terms of
②  as a result of
③  based on
④  on behalf of
【单选题】 The gardens and history of Suzhou ( ) all who visit there.
①  captivate
②  captive
③  captivation
④  captivating
【单选题】 The government would be unwise to ( ) the complaints of its people.
①  overlook
②  ignore
③  neglect
④  disrespect
【单选题】 In high school, I was very unpopular, and I did ( ) the discrimination from my classmates.
①  encountered
②  encounter
③  had encountered
④  will encounter
【单选题】 The pavilions of each country at the World Expo can reveal the ( ) cultures of the world.
①  diversity
②  diversify
③  divert
④  diverse
【单选题】 His ( ) as a social worker brings him much thinking of the meaning of life and charity.
①  job
②  profession
③  work
④  career