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