c语言用三种循环语句编写程序2+4+6+8…+100的偶数和
include <stdio.h>void main( ){int sum,i;sum=0;for(i=2;i<=100;i+=2){sum+=i;}printf("for循环计算所得值:%d\\n",sum);i=2,sum=0;while(i<=100){sum+=i;i+=2;}printf("while循环计算所得值:%d\\n",sum);i=2,sum=0;do {sum+=i;i+=2;}while(i<=100);printf(...
编写程序计算2+4+6+8...+100这个怎么写?
main(){ int i,sum;for(i=2;i<=100;i=i+2)sum=sum+i; \/*从2开始,每隔一个,循环累加*\/ printf("sum=%d\\n",sum);printf("intput a number:");scanf("%d",&i); \/*从键盘读取一个整数*\/ if(i>0) printf("it is positive");else printf("it is notpositive");}...
大一c语言编写计算2+4+6+8+...+100程序怎么设计
printf ("the num 2 +4 + ...+100= 2550");
c语言程序编写 (1) 计算1×2×3×4×5 (2) 计算2+4+6+8+…+100 +
(1) void main(){ int i,sum; sum=1;for(i=1;i<6;i++)sum*=i;printf("%d\\n",sum);}(2) void main(){ int i,sum; sum=0;for(i=2;i<101;i+=2)sum+=i;printf("%d\\n",sum)}
2+4+6+8+...+100C语言表述
include<stdio.h> int main(){ int i,sum=0;for(i=2;i<=100;i=i+2)sum=sum+i;printf("%d\\n",sum);return 0;}
求助、求助 c语言 编程求2+4+6+8+...n n值从键盘输入 谢谢大侠们_百度...
include <stdio.h> int main ( ){ int i,j,sum;sum=0;printf("请输入一个整偶数!\\n");scanf("%d",&j);for(i=2;i<=j;i+=2){ sum=sum+i;} printf("sum=%d\\n",sum);return 0;}
编写c语言程序用for语句1+2+3+4+5+6+8+……到100的和
int fun(int n){ int sum = 0;int i;for(i = 1;i <= n;i++){ sum += i;} return sum;} 若求1-100和,则这样调用fun(100);返回值即为所求和
C语言程式设计sum=2+4+6+8……96+98+100
2+4+6+8……96+98+100=( )2550 1×2×3×4×5×...×100C语言程式设计 include <stdio.h> __int64 run(int num);int main(void){ printf("1×2×3×4×5×...×10计算的结果是:%lld\\n",run(1));return 0;} __int64 run(int num){ if (num >= 10){ return num;} ...
用c语言求2+4+6+8+10+…+2n
include"stdio.h"int main(){ int i,n,s=0;scanf("%d",&n);for(i=1; i<=n; i++)s+=i;printf("%d\\n",s+s);return 0;}
用c语言求2+4+6+8+10+…+2n
如果你用的是WIN-TC的话,下面这个程序是比较简单的;如果你用的是TURBO C的话就把“getch()"改为”getchar()"就可以了。include"stdio.h"main(){int i,sum=0;for(i=2;i<=100;i++,i++){sum=i+sum;} printf("The answer is %d",sum);getch();} 我在WIN--TC中运行了一下 答案...