fork(1) download
  1. // C code
  2. // This program will calculate the perimeter of a trapezoid with two right angles
  3. // Developer: David Asake
  4. // Course: CMIS 102
  5. // Date: June 05, 2020
  6. #include <stdio.h>
  7. #include <math.h>
  8. int main(void) {
  9. /* varaiable definition */
  10. float base1, base2, height, perimeter;
  11. printf("Enter the first base of the trapezoid: 4.5 \n");
  12. base1 = 4.5;
  13. scanf("%f", &base1);
  14. printf("Enter the second base of the trapezoid: 5.8 \n");
  15. base2 = 5.8;
  16. scanf("%f", &base2);
  17. printf("Enter the height of the trapezoid: 6.9 \n");
  18. height = 6.9;
  19. scanf("%f", &height);
  20. perimeter = base1 + base2 + height + sqrt(height * height + (base2 - base1 * base2 - base1));
  21. printf("perimeter is: %f \n", perimeter);
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
Enter the first base of the trapezoid: 4.5 
Enter the second base of the trapezoid: 5.8 
Enter the height of the trapezoid: 6.9 
perimeter is: 21.975983