Archived

This topic is now archived and is closed to further replies.

What's wrong with my code? please look.

This topic is 5963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include int main() { float PI = 3.14; float radius; cout << "Please enter the radius: "; cin << radius; cout << "The circumference is " << 2*PI*radius << "." << endl; cout << "The area is " << PI*radius^2 << "."; return 0; } I get 2 errors and 1 warning in vc++6: C:\Program Files\Microsoft Visual Studio\MyProjects\circle\circle.cpp(5) : warning C4305: ''initializing'' : truncation from ''const double'' to ''float'' C:\Program Files\Microsoft Visual Studio\MyProjects\circle\circle.cpp(8) : error C2676: binary ''<<'' : ''class istream_withassign'' does not define this operator or a conversion to a type acceptable to the predefined operator C:\Program Files\Microsoft Visual Studio\MyProjects\circle\circle.cpp(10) : error C2297: ''<<'' : illegal, right operand has type ''char [2]'' Error executing cl.exe. circle.exe - 2 error(s), 1 warning(s) what''s wrong? I looked over it over and over!!

Share this post


Link to post
Share on other sites
to give you some advice, try a few things out before asking. any book on c++ would have given you the answer, or if you have MSDN handy, that''s always a good reference to look things up in. not that all of us mind these simple questions, but sometimes we also like to teach some common sense. =)

a2k

Share this post


Link to post
Share on other sites