Guest User

Untitled

a guest
Jul 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4.  
  5. double summation(long* N);
  6.  
  7. int main(void)
  8. {
  9. printf("summation of squares of first N numbersn");
  10. printf("enter Nn");
  11. long* N;
  12. *N = 0;
  13.  
  14. scanf("%lin",N);
  15.  
  16. double su;
  17. su = summation(N);
  18. printf("The summ equals %.lfn", su);
  19. return 0;
  20. }
  21.  
  22. double summation(long* N)
  23. {
  24. double S = 0;
  25. int i;
  26.  
  27. for (i = 1; i <= *N; i++)
  28. S = S + pow(i, 2);
  29. return S;
  30. }
  31.  
  32. long* N;
  33. *N = 0;
  34. scanf("%lin", N);
  35.  
  36. long N;
  37. N = 0; // this is somewhat useless BTW, because N will be modified in the line below
  38. scanf("%lin", &N);
Add Comment
Please, Sign In to add comment