Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<math.h>
  4. float fn(float x)
  5. {
  6. sqrt(x);
  7. return sqrt(x);
  8. }
  9. main()
  10. {
  11. int i,n;
  12. float a,b,s=0,y=0,h;
  13. printf("Enter the no of interval =");
  14. scanf("%d",&n);
  15. printf("Enter the lower limit=");
  16. scanf("%f",&a);
  17. printf("Enter the upper limit=");
  18. scanf("%f",&b);
  19. h=(b-a)/n;
  20. for(i=1;i<=n-1;i++)
  21. {
  22. s=s+fn(a+i*h);
  23. }
  24. y=(fn(a)+fn(b)+2*s)*h/2;
  25. printf("the value of y is=%f",y);
  26. getch();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement