Noob Help......Calculating volume and area of a sphere...

This is a discussion on Noob Help......Calculating volume and area of a sphere... within the C Programming forums, part of the General Programming Boards category; Hey guys,
I'm new to this language and am having a little problem getting the code below to run, its ...

it just means you need to put (float area, float radius, float volume) in your protoype at the top, and when you call the function in your program it needs to have this amount of parameters too, but you only have to write in the names of the variables, not the type also, then in your actual function definition (where the work is done by the function) you need to show the arguments the same as you did in the prototyp, ie with the types also,

ps the actual variable names can be different there to reflect their exact use in the function itself if you like..

it just means you need to put (float area, float radius, float volume) in your protoype at the top, and when you call the function in your program it needs to have this amount of parameters too, but you only have to write in the names of the variables, not the type also, then in your actual function definition (where the work is done by the function) you need to show the arguments the same as you did in the prototyp, ie with the types also,

ps the actual variable names can be different there to reflect their exact use in the function itself if you like..

You don't have to include the variable names in the function prototype, just the types:

You don't have to include the variable names in the function prototype, just the types:

That is true, but normally you should include the parameter names in the prototype, to aid in readability.

Originally Posted by matt.s

but it crashes when it gets to the 'printresults' function in main, saying that..

Yes. The problem is that the variables named area, radius, and volume in the main function are not related to the variables named radius, area, and volume in the volume_calc function.

What you can do is add parameters to the volume_calc function. These parameters will be pointers to the area, radius, and volume variables in the caller, i.e., the main function would pass the addresses of area, radius, and volume to volume_calc.

Getting closer. volume_calc's parameters are still doubles rather than pointers to double. You should also remove those local variables from volume_calc, and since radius would then be a pointer to double, there would be no need to pass its address to scanf.