36 lines
No EOL
1 KiB
C
36 lines
No EOL
1 KiB
C
// header files
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
// local constants
|
|
#define EDGE_LENGTH_MULTIPLIER 5
|
|
// this volume is in centimeters
|
|
#define TOP_FRACTION 5*(3 + sqrt(5))
|
|
#define BOTTOM_FRACTION 12
|
|
|
|
/*
|
|
Name: Volume of Icosahedron
|
|
Process: Given an edge of an Icosahedron, calculate the volume of the shape.
|
|
Uses a formula found on Google to calculate this.
|
|
Function input/parameters: NONE
|
|
Function output/parameters: NONE
|
|
Function output/returned: NONE
|
|
Device input/---: NONE
|
|
Device output/---: NONE
|
|
Dependencies: included by standard libraries
|
|
*/
|
|
int main()
|
|
{
|
|
// define local variables
|
|
double icosahedronVol;
|
|
// do calculations
|
|
icosahedronVol = (TOP_FRACTION / BOTTOM_FRACTION) *
|
|
(EDGE_LENGTH_MULTIPLIER * EDGE_LENGTH_MULTIPLIER * EDGE_LENGTH_MULTIPLIER);
|
|
// display results
|
|
printf("An Icosahedron with edge length %d cm has volume %f cm.\n",
|
|
EDGE_LENGTH_MULTIPLIER, icosahedronVol);
|
|
// return success
|
|
return 0;
|
|
} |