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