Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Implementations for the area of various shapes. More...
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iostream>
Namespaces | |
namespace | math |
for IO operations | |
Functions | |
template<typename T > | |
T | math::square_area (T length) |
area of a square (l * l) | |
template<typename T > | |
T | math::rect_area (T length, T width) |
area of a rectangle (l * w) | |
template<typename T > | |
T | math::triangle_area (T base, T height) |
area of a triangle (b * h / 2) | |
template<typename T > | |
T | math::circle_area (T radius) |
area of a circle (pi | |
template<typename T > | |
T | math::parallelogram_area (T base, T height) |
area of a parallelogram (b * h) | |
template<typename T > | |
T | math::cube_surface_area (T length) |
surface area of a cube ( 6 * (l | |
template<typename T > | |
T | math::sphere_surface_area (T radius) |
surface area of a sphere ( 4 * pi * r^2) | |
template<typename T > | |
T | math::cylinder_surface_area (T radius, T height) |
surface area of a cylinder (2 * pi * r * h + 2 * pi * r^2) | |
static void | test () |
Self-test implementations. | |
int | main () |
Main function. | |
Implementations for the area of various shapes.
The area of a shape is the amount of 2D space it takes up. All shapes have a formula to get the area of any given shape. These implementations support multiple return types.
int main | ( | void | ) |
|
static |
Self-test implementations.