①输入i,sum;
②用 i 统计次数,其初值置为2,定义 sum = 0;
③若i<=100,转第④步,否则转第⑦步
④得sum = i + sum;
⑤i 增加2;
⑥返回第③步;
⑦输出sum;
代码
#include<stdio.h>
int main()
{ int sum = 0, i = 2;
while (i <= 100)
{ sum = sum + i;
i = i + 2;
}
printf("sum = %d\n", sum);
return 0;
}