I'm very new to programming and I'm trying to make a program to compute the circumference of a circle when you give it the radius, but I keep getting "fatal error LNK1169: one or more multiply defined symbols found" whenever I think I fix it, it just says the same thing. What am I doing wrong?

#include <iostream>
#include <cstdlib>
#include <cmath>


using namespace std;

//////////////////////////////////////////////////////////
double pi = 3.14159265359;
 int main()
{

		float r;
		float circumference;
		float pi;
        

		cout << "What is the radius of the circle: ";
		cin >> r;
 

		circumference = 2 * pi * r;

		cout << "The circumference is " << circumference << '.' << endl;
                           
                            
	system("PAUSE");
	return(0);

} // end main

Edited 5 Years Ago by Narue: added code tags

you declared two variables named pi, one is double and the other is float. Delete one of the two (preferably the one inside main() because it is uninitialized).

Edited 5 Years Ago by Ancient Dragon: n/a

The problem is not with what you are compiling but how you are compiling it. Please tell us how you compiled this code (what OS, what compiler, what compiler command or build configuration, etc.).

EDIT: Oups, sorry, didn't notice the two pi variables. That's probably the problem.

Edited 5 Years Ago by mike_2000_17: n/a

you declared two variables named pi, one is double and the other is float. Delete one of the two (preferably the one inside main() because it is uninitialized).

I did this but it still won't work... anything else I need to change?

What compiler are you using. I just compiled it with VC++ 2010 Express, deleted the duplicate pi variable, and it compiled/linked without any errors.

This article has been dead for over six months. Start a new discussion instead.