fork download
  1. #include <stdio.h>
  2.  
  3. // **************************************************
  4. // Function: calcAreaOfTrapezoid
  5. //
  6. // Description: Calculates the area of a trapezoid
  7. //
  8. // Parameters: side1 - size of first side
  9. // side 2 - size of second side
  10. // height - size of vertical height
  11. //
  12. // Returns: area - area of trapezoid
  13. //
  14. // ***************************************************
  15.  
  16. float calcAreaOfTrapezoid(float side1, float side2, float height)
  17. {
  18. float area; // area of the trapezoid
  19.  
  20. // calculate area
  21. area = 0.5 * (side1 + side2) * height;
  22.  
  23. return (area);
  24.  
  25. } //calcAreaOfTrapezoid
  26.  
  27. int main() {
  28. float side1 = 10;
  29. float side2 = 4;
  30. float height = 8;
  31. float area;
  32.  
  33. // Test the function
  34. area = calcAreaOfTrapezoid(side1, side2, height);
  35.  
  36.  
  37. printf("%.2f\n", area);
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
56.00