#include "stdio.h"
main()
{
int x,y;
x=0;
for(y=0;y<=100;y=y+2)
x=x+y;
printf("the sum is %d\n",x);
}
使用for循环,计算2+4+6+...+100
#include "stdio.h"
main()
{
int x,y;
x=0;
for(y=0;y<=100;y=y+2)
x=x+y;
printf("the sum is %d\n",x);
}