#include<stdio.h> int main() { int n=1,sum=0; do { sum=sum+n; n++; }while(n<=100); printf("do...while语句实现1+2+3+4...+100的和为:%d\n",sum); return 0; }
C语言 利用do...while语句实现1+2+3+4...+100的和
最新推荐文章于 2024-11-02 15:25:13 发布
#include<stdio.h> int main() { int n=1,sum=0; do { sum=sum+n; n++; }while(n<=100); printf("do...while语句实现1+2+3+4...+100的和为:%d\n",sum); return 0; }