home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 98.img / LCNOW2.ZIP / EXAMPLES / TRAP.C < prev    next >
C/C++ Source or Header  |  1988-07-07  |  980b  |  34 lines

  1. /*
  2.  * T R A P
  3.  *
  4.  * Calculate the area of a trapeziod.
  5.  */
  6.  
  7. main()
  8. {
  9.     /* Variable declaration */
  10.     float area, top, base, height;
  11.  
  12.     /* Get dimensions from the user. */
  13.     printf("\n\tTRAPEZOID AREA CALCULATION\n\n");
  14.     printf("Please enter the following measurements:\n\n");
  15.     printf("               top\n");
  16.     printf("            ___________     ____\n");
  17.     printf("           /           \\      |\n");
  18.     printf("          /             \\    height\n");
  19.     printf("         /_______________\\  __|_\n");
  20.     printf("               base\n\n");
  21.     printf("Note: Please use numbers only.\n");
  22.     printf("Enter the top measurement of the trapezoid: ");
  23.     scanf("%f", &top);
  24.     printf("Enter the base measurement of the trapezoid: ");
  25.     scanf("%f", &base);
  26.     printf("Enter the height measurement of the trapezoid: ");
  27.     scanf("%f", &height);
  28.  
  29.     /* Calculate and print the area. */
  30.     area = (top + base) * height / 2;
  31.     printf("The area of the trapezoid is %.2f\n", area);
  32.  
  33. }
  34.