Repository: TheAlgorithms/C-Plus-Plus
File: math/area.cpp (C++)

Code before:
 * @brief surface area of a [sphere](https://en.wikipedia.org/wiki/Sphere) ( 4 *
 * pi * r^2)
 * @param radius is the radius of the sphere
 * @returns surface area of the sphere
 */
template <typename T>
T sphere_surface_area(T radius) {
    return 4 * M_PI * pow(radius, 2);
}

/**
 * @brief surface area of a [cylinder](https://en.wikipedia.org/wiki/Cylinder)
 * (2 * pi * r * h + 2 * pi * r^2)
 * @param radius is the radius of the cylinder
 * @param height is the height of the cylinder
 * @returns surface area of the cylinder
 */
template <typename T>
T cylinder_surface_area(T radius, T height) {
    return 2 * M_PI * radius * height + 2 * M_PI * pow(radius, 2);
}

/**
 * @brief surface area of a [hemi-sphere](https://en.wikipedia.org/wiki/Surface_area) ( 3 *
 * pi * r^2)
 * @param radius is the radius of the hemi-sphere
 * @returns surface area of the hemi-sphere
 */
template <typename T>
T hemi_sphere_surface_area(T radius) {
    return 3 * M_PI * pow(radius, 2);
}
}  // namespace math

/**
 * @brief Self-test implementations
 * @returns void
 */
static void test() {
    // I/O variables for testing
    uint16_t int_length = 0;    // 16 bit integer length input
    uint16_t int_width = 0;     // 16 bit integer width input
    uint16_t int_base = 0;      // 16 bit integer base input
    uint16_t int_height = 0;    // 16 bit integer height input
    uint16_t int_expected = 0;  // 16 bit integer expected output
    uint16_t int_area = 0;      // 16 bit integer output

    float float_length = NAN;    // float length input
    float float_expected = NAN;  // float expected output
    float float_area = NAN;      // float output


Review comment (suggestion):
```suggestion
 * @param radius is the radius of the hemi-sphere
 * @tparam T datatype of radius
```

Code after:
 * @brief surface area of a [sphere](https://en.wikipedia.org/wiki/Sphere) ( 4 *
 * pi * r^2)
 * @param radius is the radius of the sphere
 * @returns surface area of the sphere
 */
template <typename T>
T sphere_surface_area(T radius) {
    return 4 * M_PI * pow(radius, 2);
}

/**
 * @brief surface area of a [cylinder](https://en.wikipedia.org/wiki/Cylinder)
 * (2 * pi * r * h + 2 * pi * r^2)
 * @param radius is the radius of the cylinder
 * @param height is the height of the cylinder
 * @returns surface area of the cylinder
 */
template <typename T>
T cylinder_surface_area(T radius, T height) {
    return 2 * M_PI * radius * height + 2 * M_PI * pow(radius, 2);
}

/**
 * @brief surface area of a [hemi-sphere](https://en.wikipedia.org/wiki/Surface_area) ( 3 *
 * pi * r^2)
 * @param radius is the radius of the hemi-sphere
 * @tparam T datatype of radius
 * @returns surface area of the hemi-sphere
 */
template <typename T>
T hemi_sphere_surface_area(T radius) {
    return 3 * M_PI * pow(radius, 2);
}
}  // namespace math

/**
 * @brief Self-test implementations
 * @returns void
 */
static void test() {
    // I/O variables for testing
    uint16_t int_length = 0;    // 16 bit integer length input
    uint16_t int_width = 0;     // 16 bit integer width input
    uint16_t int_base = 0;      // 16 bit integer base input
    uint16_t int_height = 0;    // 16 bit integer height input
    uint16_t int_expected = 0;  // 16 bit integer expected output
    uint16_t int_area = 0;      // 16 bit integer output

    float float_length = NAN;    // float length input
    float float_expected = NAN;  // float expected output
    float float_area = NAN;      // float output