There are a number of errors here. But let's start by getting it to compile.
You should first get the user to supply the radius value, before calling the function.
The function will need to make use of the value of r just entered. You will also need to make use of the value returned from the function.
Hence the code for main might look like this:
1 2 3 4 5 6
|
float r;
cout << "provide a radius " << endl;
cin >> r;
float a = call(r);
cout << "the area is " << a << endl;
|
Also in main() you have a strange call to a function named return:
that should be
Now for the header file.
Well, the function (named
call()
though I recommend a meaningful name such as
area()
or
circle_area()
) is a bit too complicated.
It should accept a single floating point parameter (the radius) and return a floating-point value.
Instead of
I'd suggest perhaps
float area(float r)
note if you change the name to
area
, make the same change in main()
As for the calculation - well it is just
πr2.
You need to do this calculation and then return the calculated result (don't just return zero).
Also - do read the tutorial on using functions:
http://www.cplusplus.com/doc/tutorial/functions/