fork download
  1. #include <stdio.h>
  2.  
  3. int sum(int n) {
  4. int i;
  5. int c = 0;
  6.  
  7. for (i = 1; i <= n; i++) {
  8. c += i;
  9. }
  10.  
  11. return c;
  12. }
  13.  
  14. int main(void) {
  15. int a, b;
  16. a = 10;
  17. b = sum(a);
  18.  
  19. printf("1から%dまでの和は%d\n", a, b);
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1から10までの和は55