#include <stdio.h>
// **************************************************
// Function: calcAreaOfTriangle
//
// Description: Calculates the area of a triangle
//
// Parameters: base - base of the triangle
// height - height of the triangle
//
// Returns: area - area of triangle
// ***************************************************
float calcAreaOfTriangle(float base, float height) {
float area; // area of the triangle
// calculate area
area = 0.5 * base * height;
return area;
} // calcAreaOfTriangle
// **************************************************
// Function: calcAreaOfCircle
//
// Description: Calculates the area of a circle
//
// Parameters: radius - radius of the circle
//
// Returns: area - area of circle
// ***************************************************
float calcAreaOfCircle(float radius) {
float area; // area of the circle
// calculate area
area = 3.14159 * radius * radius;
return area;
} // calcAreaOfCircle
// **************************************************
// Function: calcAreaOfSquare
//
// Description: Calculates the area of a square
//
// Parameters: side - side length of the square
//
// Returns: area - area of square
// ***************************************************
float calcAreaOfSquare(float side) {
float area; // area of the square
// calculate area
area = side * side;
return area;
} // calcAreaOfSquare
// **************************************************
// Function: calcAreaOfRectangle
//
// Description: Calculates the area of a rectangle
//
// Parameters: width - width of the rectangle
// height - height of the rectangle
//
// Returns: area - area of rectangle
// ***************************************************
float calcAreaOfRectangle(float width, float height) {
float area; // area of the rectangle
// calculate area
area = width * height;
return area;
} // calcAreaOfRectangle
// **************************************************
// Function: calcAreaOfParallelogram
//
// Description: Calculates the area of a parallelogram
//
// Parameters: base - base of the parallelogram
// height - height of the parallelogram
//
// Returns: area - area of parallelogram
// ***************************************************
float calcAreaOfParallelogram(float base, float height) {
float area; // area of the parallelogram
// calculate area
area = base * height;
return area;
} // calcAreaOfParallelogram
// **************************************************
// Function: calcAreaOfTrapezoid
//
// Description: Calculates the area of a trapezoid
//
// Parameters: a - length of the first parallel side
// b - length of the second parallel side
// height - height of the trapezoid
//
// Returns: area - area of trapezoid
// ***************************************************
float calcAreaOfTrapezoid(float a, float b, float height) {
float area; // area of the trapezoid
// calculate area
area = 0.5 * (a + b) * height;
return area;
} // calcAreaOfTrapezoid
int main() {
// Example usage
printf("Area of Triangle: %f\n", calcAreaOfTriangle
(5.0, 10.0)); printf("Area of Circle: %f\n", calcAreaOfCircle
(5.0)); printf("Area of Square: %f\n", calcAreaOfSquare
(4.0)); printf("Area of Rectangle: %f\n", calcAreaOfRectangle
(4.0, 6.0)); printf("Area of Parallelogram: %f\n", calcAreaOfParallelogram
(5.0, 10.0)); printf("Area of Trapezoid: %f\n", calcAreaOfTrapezoid
(3.0, 4.0, 5.0));
return 0;
}