fork download
  1. // C code
  2. // This program will calculate the area of a trapezoid. // Developer: Faculty CMIS102
  3. // Date: Mar 23, 2019
  4. #include <stdio.h>
  5. #include <math.h>
  6. int main () {
  7. printf("Lab3 Math Formulas by:William Klingesetin\n");
  8. /* variable definition: */
  9. float baseA, baseB, height, area;
  10. /* Prompt user for baseA */
  11. printf("Enter the first base of the trapezoid: \n"); // Input the base
  12. scanf("%f", &baseA);
  13. /* Prompt user for baseB */
  14. printf("Enter the second base of the trapezoid: \n"); // Input the baseB
  15. scanf("%f", &baseB);
  16. /* Prompt user for height */
  17. printf("Enter the height of the trapezoid: \n");
  18. // Input the height
  19. scanf("%f", &height);
  20. // Calculate the perimeter
  21. perimeter = baseA + baseB + height +
  22. sqrt (height*height + (baseA – baseB)*(baseA – baseB));
  23. // Print the result
  24. printf("perimeter is : %f\n", perimeter);
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:21:1: error: ‘perimeter’ undeclared (first use in this function)
 perimeter = baseA + baseB + height +
 ^~~~~~~~~
prog.c:21:1: note: each undeclared identifier is reported only once for each function it appears in
prog.c:22:30: error: stray ‘\342’ in program
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                              ^
prog.c:22:31: error: stray ‘\200’ in program
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                               ^
prog.c:22:32: error: stray ‘\223’ in program
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                                ^
prog.c:22:34: error: expected ‘)’ before ‘baseB’
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                                  ^~~~~
prog.c:22:48: error: stray ‘\342’ in program
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                                                ^
prog.c:22:49: error: stray ‘\200’ in program
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                                                 ^
prog.c:22:50: error: stray ‘\223’ in program
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                                                  ^
prog.c:22:52: error: expected ‘)’ before ‘baseB’
 sqrt (height*height + (baseA – baseB)*(baseA – baseB));
                                                    ^~~~~
prog.c:9:29: warning: unused variable ‘area’ [-Wunused-variable]
 float baseA, baseB, height, area;
                             ^~~~
stdout
Standard output is empty