Hi, i'm new to programming and don't have much experience, but have decided to take a course at uni. We've been doing user defined functions and have got stuck on this one. Basically, the code compiles and runs, but it only returns a value of 1, no matter what i set the variables to. The problem is in the volcyl function. I've posted the code below:
using namespace std;
double volcyl(double radius, double height); //returns the volume of a cylinder
double radius = 1; //sets value of radius
double height = 1; //sets value of height
cout << "r h V" << endl;
cout << radius << " " << height << " " << volcyl << endl; //cout radius, height and volume of cylinder
//Define function "volcyl" - calculates the volume of a cylinder
It's probably a simple thing i've got wrong but i've been trying to get it to work for the last hour with no success. I've tried re-organising the code to no avail, and have had a good route round on the internet, for a solution but can't find one.
Like i said it's probably a simple problem but i can't figure it out, so any help would be appreciated.