第二章 2.4小节 5-1-1连续自然数求和

该编程题网址

http://codeup.cn/problem.php?cid=100000568&pid=0

题目描述

求1+2+3+...+100,即求

要求用while语句实现

输入

输出

要求的和,末尾输出换行。

样例输入 Copy

样例输出 Copy

5050
#include <stdio.h>
int main(){
    int i=1,sum=0;
    char h;
    scanf("%c",&h);
    while(i<=100){
        sum+=i;
        i++;
    }
    printf("%d",sum);
    return 0;
}
原文地址:https://www.cnblogs.com/xxl-h/p/12864003.html