++ Homework 2 Files

This commit is contained in:
Charles Descamps 2023-09-27 20:07:19 -07:00
parent 90652a17ce
commit 6269fbc4ce
10 changed files with 191 additions and 0 deletions

36
Homework2/volume.c Normal file
View file

@ -0,0 +1,36 @@
// 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;
}