fork download
  1. // C code
  2. // This program will calculate the area of a trapezoid.
  3. // Developer: Faculty CMIS102
  4. // Date: Jan 31, XXXX
  5. #include <stdio.h>
  6. int main ()
  7. {
  8. /* variable definition: */
  9. float baseA, baseB, height, area;
  10. /* Prompt user for baseA */
  11. printf("Enter the first base of the trapezoid: \n");
  12. // Input the base
  13. scanf("%f", &baseA);
  14. /* Prompt user for baseB */
  15. printf("Enter the second base of the trapezoid: \n");
  16. // Input the baseB
  17. scanf("%f", &baseB);
  18. /* Prompt user for height */
  19. printf("Enter the height of the trapezoid: \n");
  20. // Input the height
  21. scanf("%f", &height);
  22. // Calculate the Area
  23. area= 0.5 * (baseA+ baseB) * height;
  24. // Print the result
  25. printf("Area is : %f\n", area);
  26. return 0;
  27. }
Success #stdin #stdout 0s 4340KB
stdin
Standard input is empty
stdout
Enter the first base of the trapezoid: 
Enter the second base of the trapezoid: 
Enter the height of the trapezoid: 
Area is : -0.000000