/**
文件名称:前一百项和.c
作者:安理计算机 杨腾飞
日期:2019.2.10
版本:v1.1(从输入数开始的前一百项自然数之和)
*/
#include<stdio.h>
main()
{
int i,root; //定义中间变量,输入数
int add=0; //定义自然数的和
printf("Please input the root number:\n");
scanf("%d",&root);
for(i=root;i<(100+root);i++)
{
add=add+i;
}
printf("The first one hundred number's sum is %d\n",add);
}
/* v1.0 前一百项自然数之和
#include<stdio.h>
main()
{
int i;
int add=0;
for(i=1;i<100;i++)
{
add=add+i;
}
printf("The first one hundred natural number's sum is %d\n",add);
}
*/