Advertisement
orneto

trapézio

Jun 25th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #define comprimento 3
  5. int main(){
  6. float x[comprimento]={1,2,1/21};
  7. float y[comprimento];
  8. int i;
  9. for(i=0; i<comprimento; i++){
  10. y[i]=(1/x[i]);
  11. }
  12. int m=comprimento-1;
  13. float y0=y[0];
  14. float ym=y[m];
  15. float a=x[0], b=x[comprimento];
  16. float h=(b-a)/m //formula do intervalo
  17. float soma=0;
  18. for(i=0; i<comprimento; i++){
  19. soma=soma+y[i];
  20. }
  21. float I=h/2*(y0+ym+2*soma);
  22. printf("%f", I);
  23.  
  24. return 0
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement