1.for 循环
#include<stdio.h>
int main()
{
int i,sum = 0;
for(i=1;i<=100;i++)
sum+=i;
printf("%d\n",sum);
}
2.while 循环
#include<stdio.h>
int main()
{
int i,sum = 0;
i=1;
while(i<=100)
{
sum+=i;
i++;
}
printf("%d\n",sum);
}
3.do-while循环
#include<stdio.h>
int main()
{
int i,sum = 0;
i=1;
do
{
sum+=i;
i++;
}
while(i<=100);
printf("%d\n",sum);
}