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