1. ## General math functions header

Sorry if this is the wrong place to post this, but since it said it was a place to share code...

I got bored after chores .

Code:
/* General math functions header file, (c) Sam Tootell. This piece of code
** was madeto be used openly and freely, as if under the GNU GPL.
*/

double pi = 3.1428571428571428571428571428571; /*For use with geometric functions, which is currently just a circle area*/

float add(float value1=0.0, float value2=0.0, float value3=0.0, float value4=0.0, float value5=0.0)
{
float endValue = value1 + value2 + value3 + value4 + value5;

/*cout << "\nThe sum is " << endValue << ".\n";*/
/*printf("\nThe sum is %f.\n" endValue);*/

return endValue;

}

/*Subtraction*/

float subtract(float sub-value1 =0.0, float sub-value2=0.0, float sub-value3=0.0, float sub-value4=0.0, float sub-value5=0.0)

{
float sub-endValue = sub-value1 - subvalue2 - subvalue3 - subvalue4 - subvalue5;

/*cout << "\nThe difference is " << sub-endValue; << ".\n";*/
/*printf("\nThe difference is %f.\n" sub-endValue);*/

return sub-endValue;

}

/*Multiplication*/

float multiply(float mult-value1=0.0, float mult-value2=0.0, float mult-value3=0.0, float mult-value4=0.0, float mult-value5=0.0)

{
float mult-endValue = mult-value1 * mult-value2 * mult-value3 * mult-value4 * mult-value5;

/*cout << "\nThe product is " << mult-endValue << ".\n";*/
/*printf("\nThe product is %f.\n" mult-endValue);*/

return mult-endValue;

}

/*Division*/

float divide(float divi-value1=0.0, divi-value2=0.0, divi-value3=0.0, divi-value4=0.0, divi-value5=0.0)

{
float divi-endValue = divi-value1 / divi-value2 / divi-value3 / divi-value4 / divi-value5;

/*cout << "\nThe difference is " << divi-endValue << ".\n";*/
/*printf("\nThe difference is %f.\n" divi-endValue);*/

return divi-endValue;

}

/*Division, but gives remainders*/

float remainder(float remain-value1, float remain-value2)

{
float remaniderOfValues1 = remain-value1 % remain-value2;
float remainderOfValues2 = remain-value2 % remain-value1;

/*cout << "\nThe remainder of << remain-value1 divided by remain-value2 is:" \
" " << remainderOfValues1 << ". The remainder of " << remain-value2 << " divided" \
" by " << remain-value1 << " is: " << remainderOfValues2 << "./n"; */

/*printf("\nThe remainder of %f divided by %f is: %f.\n"remain-value1,remain-value2,remainderOfValues1);
printf("\nThe remainder of %f divided by %f is: %f.\n"remain-value2,remain-value1,remainderOfValues2); */

return remainderOfValues1; /*Not sure if I can return two at a time... I won't risk it*/

}

/*Pythagoream Theorem*/

float pythTheorem(float a, float b)

{

float c = a^2 + b^2;

/*cout << "\nFor << a << "^2 and << b << "^2, the result is << c << "^2.\n;*/
/*printf("\nFor %f^2 and %f^2, the result is %f^2.\n" a,b,c);*/

return c;

}

/*Exponentation*/

float exponent(float exp-value1, float exp-value2)

{
float exp-endValue = exp-value1 ^ exp-value2;

/*cout << "\nThe exponentation of " << exp-value1 << " and " << exp-value2 << " is " << \
exp-EndValue << ".\n*/

/*printf("\nThe exponentation of %f and %f is %f\n" exp-value1, exp-value2, exp-endValue);*/

return exp-endValue;

}

/*================Geometry================*/

/*Circle area*/

{
double area = pi * (radius ^ 2);

/*cout << "\nFor radius = " << radius << ", the result is: \n " << area << "\n"*/

return area;

}

/*Circle circumference*/

{

/*cout << "\nFor radius = " << radius-circ << ", the circle circumference is: " << circumference << ".\n";

return circumference;

}

/*Cube Volume*/

float cubeVolume(float side)

{
float volume = side^3;

/*cout << "\nFor any side of the cube being " << side << " units, the volume is " << volume << " units^3.\n";
/*printf("\nFor any side of the cube being %f units, the volume is %f units^3.\n" side, volume*/

return volume;

}

/* I'll work on more geometry later, and maybe even put in prompting functions... no guarantee*/
Hope you can get some use out of it .

2. lol, you must be really bored. All I have to say is why not use
#define PI 3.14159...

3. Good question...

Code:
/* General math functions header file, (c) Sam Tootell. This piece of code
** was madeto be used openly and freely, as if under the GNU GPL.
*/

/*double pi = 3.1428571428571428571428571428571; /*For use with geometric functions, which is currently just a circle area*/ */

#define PI = 3.142857;

float add(float value1=0, float value2=0, float value3=0, float value4=0, float value5=0)
{
float endValue = value1 + value2 + value3 + value4 + value5;

/*cout &lt;&lt; "\nThe sum is " &lt;&lt; endValue &lt;&lt; ".\n";*/
/*printf("\nThe sum is %f.\n" endValue);*/

return endValue;

}

/*Subtraction*/

float subtract(float sub-value1=0, float sub-value2=0, float sub-value3=0, float sub-value4=0, float sub-value5=0)

{
float sub-endValue = sub-value1 - subvalue2 - subvalue3 - subvalue4 - subvalue5;

/*cout &lt;&lt; "\nThe difference is " &lt;&lt; sub-endValue; &lt;&lt; ".\n";*/
/*printf("\nThe difference is %f.\n" sub-endValue);*/

return sub-endValue;

}

/*Multiplication*/

float multiply(float mult-value1=0, float mult-value2=0, float mult-value3=0, float mult-value4=0, float mult-value5=0)

{
float mult-endValue = mult-value1 * mult-value2 * mult-value3 * mult-value4 * mult-value5;

/*cout &lt;&lt; "\nThe product is " &lt;&lt; mult-endValue &lt;&lt; ".\n";*/
/*printf("\nThe product is %f.\n" mult-endValue);*/

return mult-endValue;

}

/*Division*/

float divide(float divi-value1=0, divi-value2=0, divi-value3=0, divi-value4=0, divi-value5=0)

{
float divi-endValue = divi-value1 / divi-value2 / divi-value3 / divi-value4 / divi-value5;

/*cout &lt;&lt; "\nThe difference is " &lt;&lt; divi-endValue &lt;&lt; ".\n";*/
/*printf("\nThe difference is %f.\n" divi-endValue);*/

return divi-endValue;

}

/*Division, but gives remainders*/

float remainder(float remain-value1, float remain-value2)

{
float remaniderOfValues1 = remain-value1 % remain-value2;
float remainderOfValues2 = remain-value2 % remain-value1;

/*cout &lt;&lt; "\nThe remainder of &lt;&lt; remain-value1 divided by remain-value2 is:" \
" " &lt;&lt; remainderOfValues1 &lt;&lt; ". The remainder of " &lt;&lt; remain-value2 &lt;&lt; " divided" \
" by " &lt;&lt; remain-value1 &lt;&lt; " is: " &lt;&lt; remainderOfValues2 &lt;&lt; "./n"; */

/*printf("\nThe remainder of %f divided by %f is: %f.\n"remain-value1,remain-value2,remainderOfValues1);
printf("\nThe remainder of %f divided by %f is: %f.\n"remain-value2,remain-value1,remainderOfValues2); */

return remainderOfValues1; /*Not sure if I can return two at a time... I won't risk it*/

}

/*Pythagoream Theorem*/

float pythTheorem(float a, float b)

{

float c = a^2 + b^2;

/*cout &lt;&lt; "\nFor &lt;&lt; a &lt;&lt; "^2 and &lt;&lt; b &lt;&lt; "^2, the result is &lt;&lt; c &lt;&lt; "^2.\n;*/
/*printf("\nFor %f^2 and %f^2, the result is %f^2.\n" a,b,c);*/

return c;

}

/*Exponentation*/

float exponent(float exp-value1, float exp-value2)

{
float exp-endValue = exp-value1 ^ exp-value2;

/*cout &lt;&lt; "\nThe exponentation of " &lt;&lt; exp-value1 &lt;&lt; " and " &lt;&lt; exp-value2 &lt;&lt; " is " &lt;&lt; \
exp-EndValue &lt;&lt; ".\n*/

/*printf("\nThe exponentation of %f and %f is %f\n" exp-value1, exp-value2, exp-endValue);*/

return exp-endValue;

}

/*================Geometry================*/

/*Circle area*/

{
double area = PI * (radius ^ 2);

/*cout &lt;&lt; "\nFor radius = " &lt;&lt; radius &lt;&lt; ", the result is: \n " &lt;&lt; area &lt;&lt; "\n"*/

return area;

}

/*Circle circumference*/

{

/*cout &lt;&lt; "\nFor radius = " &lt;&lt; radius-circ &lt;&lt; ", the circle circumference is: " &lt;&lt; circumference &lt;&lt; ".\n";

return circumference;

}

/*Cube Volume*/

float cubeVolume(float side)

{
float volume = side^3;

/*cout &lt;&lt; "\nFor any side of the cube being " &lt;&lt; side &lt;&lt; " units, the volume is " &lt;&lt; volume &lt;&lt; " units^3.\n";
/*printf("\nFor any side of the cube being %f units, the volume is %f units^3.\n" side, volume*/

return volume;

}

/* I'll work on more geometry later, and maybe even put in prompting functions... no guarantee*/

Yea, I was REALLY bored that night .

4. Sorry to bring back "old" thread, but I just came across this one...

1. I know in school they told us PI ~ 22/7, but PI is NOT 22/7. PI is 3.141592653589793238...
Just google for 3.1415926535 and you'll find the higher precision values (I've seen up to 50 digits).

2. Have you tried to make use of the header file (#include and anything)?
The use of dash in variable names caught my eyes right away, also the first line of subtrack().
But then I let my compiler to decide anyway, and yes, it complains...

Now that's what I call bored.

Peace always,
&lt;jdenny&gt;

5. Hi

...which brings me to the most useless url I have ever seen:

http://3.141592653589793238462643383...974944592.com/

edit: the url in two pieces
3.141592653589793238462643383279502
884197169399375105820974944592.com

Cheers.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

×