Thursday, July 9, 2009

Need help with programming a C++ program to find circumference with a given radius.?

This is what I have:


#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


#include %26lt;iomanip%26gt;


using namespace std;


double pi=3.14159;





int main ()


{


cout %26lt;%26lt;"Michael ..MJNL6P2.cpp Lab#6 C++ Tutorial \n" %26lt;%26lt; endl;








double radius;





ofstream outfile;


outfile.open("circle.out");





cout %26lt;%26lt;"ENTER LENGTH FOR RADIUS: " ;





cin %26gt;%26gt; radius;


double CIRCUMFERENCE = 2 * pi * radius;





cout %26lt;%26lt; "Circumference is " %26lt;%26lt; CIRCUMFERENCE %26lt;%26lt; " \n\n\n";


outfile %26lt;%26lt; "Circumference is " %26lt;%26lt; CIRCUMFERENCE %26lt;%26lt; ".\n";








return 0;


}





I get the errors:


PYRMJN-1.obj : error LNK2005: _main already defined in MJNL6P2.obj


Debug/MJNL6P2.exe : fatal error LNK1169: one or more multiply defined symbols found


Error executing link.exe.

Need help with programming a C++ program to find circumference with a given radius.?
hmmm....thats a weird error message. Cant say Ive seen it before. It shouldnt be anything to do with your actual code, looks good to me.





Im guessing it has something to do with how you are compiling it. What are you using?





If you are using g++ you can do it all in one line.


g++ thisFile.cpp -o pgm.exe


No comments:

Post a Comment