// C code
// This program will calculate the area of a trapezoid. // Developer: Faculty CMIS102
// Date: Mar 23, 2019
#include <stdio.h>
#include <math.h>
int main () {
printf("Lab3 Math Formulas by:William Klingesetin\n"); /* variable definition: */
float baseA, baseB, height, area;
/* Prompt user for baseA */
printf("Enter the first base of the trapezoid: \n"); // Input the base /* Prompt user for baseB */
printf("Enter the second base of the trapezoid: \n"); // Input the baseB /* Prompt user for height */
printf("Enter the height of the trapezoid: \n"); // Input the height
// Calculate the perimeter
perimeter = baseA + baseB + height +
sqrt (height
*height
+ (baseA – baseB
)*(baseA – baseB
)); // Print the result
printf("perimeter is : %f\n", perimeter
); return 0;
}
Ly8gQyBjb2RlCi8vIFRoaXMgcHJvZ3JhbSB3aWxsIGNhbGN1bGF0ZSB0aGUgYXJlYSBvZiBhIHRyYXBlem9pZC4gLy8gRGV2ZWxvcGVyOiBGYWN1bHR5IENNSVMxMDIKLy8gRGF0ZTogTWFyIDIzLCAyMDE5CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8bWF0aC5oPgppbnQgbWFpbiAoKSB7CglwcmludGYoIkxhYjMgTWF0aCBGb3JtdWxhcyBieTpXaWxsaWFtIEtsaW5nZXNldGluXG4iKTsKLyogdmFyaWFibGUgZGVmaW5pdGlvbjogKi8KZmxvYXQgYmFzZUEsIGJhc2VCLCBoZWlnaHQsIGFyZWE7Ci8qIFByb21wdCB1c2VyIGZvciBiYXNlQSAqLwpwcmludGYoIkVudGVyIHRoZSBmaXJzdCBiYXNlIG9mIHRoZSB0cmFwZXpvaWQ6IFxuIik7IC8vIElucHV0IHRoZSBiYXNlCnNjYW5mKCIlZiIsICZiYXNlQSk7Ci8qIFByb21wdCB1c2VyIGZvciBiYXNlQiAqLwpwcmludGYoIkVudGVyIHRoZSBzZWNvbmQgYmFzZSBvZiB0aGUgdHJhcGV6b2lkOiBcbiIpOyAvLyBJbnB1dCB0aGUgYmFzZUIKc2NhbmYoIiVmIiwgJmJhc2VCKTsKLyogUHJvbXB0IHVzZXIgZm9yIGhlaWdodCAqLwpwcmludGYoIkVudGVyIHRoZSBoZWlnaHQgb2YgdGhlIHRyYXBlem9pZDogXG4iKTsKLy8gSW5wdXQgdGhlIGhlaWdodApzY2FuZigiJWYiLCAmaGVpZ2h0KTsKLy8gQ2FsY3VsYXRlIHRoZSBwZXJpbWV0ZXIgCnBlcmltZXRlciA9IGJhc2VBICsgYmFzZUIgKyBoZWlnaHQgKwpzcXJ0IChoZWlnaHQqaGVpZ2h0ICsgKGJhc2VBIOKAkyBiYXNlQikqKGJhc2VBIOKAkyBiYXNlQikpOyAKLy8gUHJpbnQgdGhlIHJlc3VsdApwcmludGYoInBlcmltZXRlciBpcyA6ICVmXG4iLCBwZXJpbWV0ZXIpOwpyZXR1cm4gMDsKfQ==
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;
^~~~