cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Logical error
Logical error
Sep 22, 2015 at 2:51pm UTC
BEARS
(43)
What is logically wrong with this code fragment??
double
x = 4/3
I think the way to fix this 2ould be to use a const, but I'm not sure what the logical error is in the first place. Why won't the original code work. I'm massive noob so please explain!!
Sep 22, 2015 at 2:56pm UTC
mutexe
(2372)
Try:
double
x = 4/3.0;
you have integer division issues (google it).
also google "c++ static_cast"
Last edited on
Sep 22, 2015 at 2:57pm UTC
Topic archived. No new replies allowed.