fork download
  1. int calculate(long long bottom,long long top) {
  2.  
  3. long long sum = 0;
  4.  
  5. if (top > bottom) {
  6.  
  7. for (long long num = bottom; num <= top; num++) {
  8. sum += num;
  9.  
  10.  
  11. };
  12. return sum;
  13.  
  14. }
  15. else {
  16. return 0;
  17. }
  18. }
  19.  
  20.  
  21. int main(){
  22. int x = calculate(1,4);
  23. printf("calculate(1,4) = %d\n", x);
  24.  
  25. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
calculate(1,4) = 10