关于 while do while for 算1~100的和
#include <stdio.h>int main (){
int sum=0,num;
for(num=1;num<=100;num++)
{
sum+=num;
}
printf("sum=%d\n",sum);
int sum1=0,num1=0;
while(++num1<=100)
{
sum1+=num1;
}
printf("sum1=%d\n",sum1);
int sum2=0,num2=1;
do{sum2+=num2;}
while(++num2<=100);
printf("sum2=%d\n",sum2);
return 0;
}
这些都是求1+2+3+。。。。+100的和
为什么用while时num1不能用后加加,而且初始值要为0
用do while时num2也是用的前加加,初始值要用1??