fork download
  1. #include <stdio.h>
  2. //課題1:1からnまでの和wp求めるコードを完成させてください
  3. int sum(int n){
  4. int c = 0;
  5. do{
  6. c+= n;
  7. } while(n-->0);
  8.  
  9. return c;
  10. }
  11. int main(void) {
  12. int a,b;
  13. a = 10;
  14. b = sum(a);
  15. printf("1から%dまでの和は%d",a,b);
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
1から10までの和は55