fork download
  1. #include <stdio.h>
  2. int sum(int n){
  3. int w = 0;
  4. for(int i=1;i<=n;i++){
  5. w+=i;
  6. }
  7. return w;
  8. }
  9.  
  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 5288KB
stdin
Standard input is empty
stdout
1から10までの和は55