logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/jun10/circle.h

/*
	this is where we are defining our functions used in circle.c

*/

//if we needed any include statements, they'd go here
// we did not use any outside functions here, so therre are no includes needed


#define PI 3.141592653589793 //pi to 15 decimial places, as doubles can handle up to 15 decimal places

/*
 the #define statement up above tells the compiler that wherever it sees "PI" that 
 means the number i gave it. 

 #define statments are good if you are dealing with a constant in multiple places in your program.

*/

double areaCircle(double r){ //function for area of the circle

	return PI * r * r;

}

double circumCircle(double r){ //function to find the circumference of a circle

	return 2 * PI * r;

}


//write a function that finds the volume of a cylinder
//Volume = pi * radius * height

double volCylinder(double r, double h){

	return PI * r * h;

}

/*

it's not often that i can write functions using only one line in the 
body, but we can do this here, as literally all i'm doing is calculating 
a value and returning it. 

*/