Problem with area of circle program

• 01-27-2013
Drezden
Problem with area of circle program
Hi

The program itself is running fine at first, but for some reason when I enter the radius for multiplication, I keep getting the Area result as 0.
Any help would be much appreciated! ;) :)

Code:

```#include <stdio.h> #include <conio.h> #define PI 3.141569 float process(float radius); int main() { float area, radius; int count; printf("To STOP, enter 0 for the radius\n"); printf("Radius = ? "); scanf("%f", &radius); for (count = 1; radius !=0; ++count) { if (radius < 0) area = 0; else area = process(radius); printf("Area = %f\n", area); printf("\nRadius = ? "); scanf("%f", &radius); } } float process(float radius) { float a; a = PI * r * r; getch(); return 0; } ```
• 01-27-2013
stahta01
Code:

```float process(float radius) { float a; a = PI * r * r; getch(); return 0; }```
• 01-27-2013
zmone
My friend the errors are in the function process... you've passed by copy the fload radius but in the function you use a variable r that isn't declared (first error) so you have to replace the R with the RADIUS passed in the function :-) and the second error is that into the function you've returned 0, logically anything that u have typed in the main would be 0!!! you have to return the variable 'a' and you have to calculate as 'a = PI * radius * radius; like following:

Code:

```float process(float radius){ float a; a = PI * radius * radius; return a; }```
so also the getch is unuseful... and also the library conio.h is unuseful for this type of program :)
• 01-27-2013
Drezden
Edited the code as suggested and I've got the following errors. :( Any suggestions?
error LNK2005: _main already defined in n.obj

error LNK2005: "float __cdecl process(float)" (?process@@YAMM@Z) already defined in n.obj
fatal error LNK1169: one or more multiply defined symbols found
• 01-27-2013
nonpuz
Your linker is telling you that it already has a definition for a function called 'process' that returns a float and operates on a float. Meaning the file n.obj has a function defined:
Code:

```float process(float somevar) { ... }```
And you are including that object file in your compilation of THIS code.