fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. float s_trap_brut (float a, float b, float step){
  5.  
  6. if((a == b) || (step == 0.0))
  7. return 0.0;
  8.  
  9. float sum = 0;
  10. float i;
  11. for(i = a; i < b; i += step){
  12. sum += ((pow(M_E, i) + pow(M_E, i+step)) * step) / 2;
  13. }
  14.  
  15. return sum;
  16. }
  17.  
  18. int main(void) {
  19.  
  20. printf("S trapez: %f", s_trap_brut(0, 1, 0.1));
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
S trapez: 1.719714