home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
98.img
/
LCNOW2.ZIP
/
EXAMPLES
/
TRAP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-07-07
|
980b
|
34 lines
/*
* T R A P
*
* Calculate the area of a trapeziod.
*/
main()
{
/* Variable declaration */
float area, top, base, height;
/* Get dimensions from the user. */
printf("\n\tTRAPEZOID AREA CALCULATION\n\n");
printf("Please enter the following measurements:\n\n");
printf(" top\n");
printf(" ___________ ____\n");
printf(" / \\ |\n");
printf(" / \\ height\n");
printf(" /_______________\\ __|_\n");
printf(" base\n\n");
printf("Note: Please use numbers only.\n");
printf("Enter the top measurement of the trapezoid: ");
scanf("%f", &top);
printf("Enter the base measurement of the trapezoid: ");
scanf("%f", &base);
printf("Enter the height measurement of the trapezoid: ");
scanf("%f", &height);
/* Calculate and print the area. */
area = (top + base) * height / 2;
printf("The area of the trapezoid is %.2f\n", area);
}