Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- float func(float);
- float leftrect(float, float, int);
- int main() {
- printf("%f",leftrect(0,4,1000));
- return 0;
- }
- float func(float x)
- {
- float res;
- res=x*x;
- return res;
- }
- float leftrect(float a, float b, int N)
- {
- int i;
- float h;
- float s;
- s=0;
- h=(b-a)/N;
- for(i=0;i<=N-1;i++)
- {
- s=s+func(a+i*h);
- }
- s=s*h;
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement