#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
最新推荐文章于 2023-10-31 15:45:01 发布
#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);
}