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

Recommended Answers

All 6 Replies

How many variables do you have named "pi"?

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).

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.

I deleted the double pi but it still says the same thing.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.