Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. int sumfunc(int i);
  2.  
  3. int main(void){
  4. int n;
  5.  
  6. printf("Enter n = %d\n", n);
  7. scanf("%d",&n);
  8.  
  9. /* I HAVE TO DO SOMETHING HERE????*/
  10.  
  11. printf("The sum of the integers from %d to %d is %d", m, n, sum);
  12.  
  13. return 0;
  14. }
  15.  
  16.  
  17. int sumfunc(int i)
  18. int n, m=1, i,sum, result;
  19.  
  20. scanf("%d",&n);
  21.  
  22. if(n>=0){
  23. for(i=0;i<=n;i++){
  24. sum += i;
  25. }
  26. }else if (n < 0){
  27. for(i=n;i<0; i++){
  28. sum+=i;
  29.  
  30. }
  31. m = -1;
  32. }
  33. else{
  34. sum=0;
  35. m=0;
  36. }
  37.  
  38. return result;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement