#include "stdio.h"
void main()
{
int i=2,sum=0;
while(i<102)
{
sum+=i;
i=i+2;
}
printf("The sum of them is %d\n",sum);
}
使用while循环,计算2+4+6+...+100

#include "stdio.h"
void main()
{
int i=2,sum=0;
while(i<102)
{
sum+=i;
i=i+2;
}
printf("The sum of them is %d\n",sum);
}