### Use of Functions in Calculations

Hello. I'm experimenting with functions and cannot get this program to run. I'm receiving an error: fatal error LNK1120. I'd appreciate any help. Thanks

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546`` `````` #define _USE_MATH_DEFINES #include #include #include using namespace std; double volumeCalculation(double radiusSphere); int main(){ double volumeSphere; double radiusSphere; double finalRadius; double incrementRadius; //Request for user input values cout << "Please input a value for the intial value of the radius (Ex Input (mm) :12 )\n"; cin >> radiusSphere; cout << "Please input a value for the final value of the radius (Ex Input (mm) :12 )\n"; cin >> finalRadius; cout << "Please input a value for the increment for the radius (Ex Input (mm) :12 )\n"; cin >> incrementRadius; //volumeCalculation Function double volumeCalculation(double radiusSphere); { volumeSphere = (4*M_PI*(pow(radiusSphere,3)/3)); } //While loop - Outputs Values and uses volumeCalculation function while (radiusSphere <= finalRadius) { volumeCalculation(radiusSphere); cout << "The volume of a sphere with a radius of " << radiusSphere << " mm is " << volumeSphere << " mm3.\n"; radiusSphere = radiusSphere + incrementRadius; } return 0; } ``````
Move this outside of the main function
 ``12345`` ``````//volumeCalculation Function double volumeCalculation(double radiusSphere)// and loose this semicolon; { volumeSphere = (4*M_PI*(pow(radiusSphere,3)/3)); }``````
Hello there.

1. Your function should be written outside main( after main's {} ). And semi-colon only at function prototype.

2. Your function should return a double, yet there is no return at all( return randomVariable ).

3. Your function call seems correct but you forgot to use a variable to store it's return value. You created it, but you have to use it. ;) Another option is to use the function call with that last cout in your program.

4. English is not my mother tongue, forgive any mistakes. :p
Thank you very much for your help, admkrk and Locien. I have fixed the issue. I appreciate it.

Your English is fine Locien, don't worry =)
Topic archived. No new replies allowed.