Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. float func(float);
  4. float leftrect(float, float, int);
  5. int main() {
  6. printf("%f",leftrect(0,4,1000));
  7. return 0;
  8. }
  9. float func(float x)
  10. {
  11. float res;
  12. res=x*x;
  13. return res;
  14. }
  15. float leftrect(float a, float b, int N)
  16. {
  17. int i;
  18. float h;
  19. float s;
  20. s=0;
  21. h=(b-a)/N;
  22. for(i=0;i<=N-1;i++)
  23. {
  24. s=s+func(a+i*h);
  25. }
  26. s=s*h;
  27. return s;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement