division problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

division problem

when i divide 100 by 3 in a double i should get 33.33 but i'm getting 33 so i cant do a coach code what i'm a doing wrong

2nd Sep 2022, 3:45 PM
Sean Methot
Sean Methot - avatar
1 Answer
+ 1
Sean Methot 100 and 3 are int value and when you divide int value then it returns whole positive number. So to get in decimal cast with either float or double to any value like cout << (double) 100 / 3; Or cout << 100 / (double) 3;
2nd Sep 2022, 4:28 PM
A͢J
A͢J - avatar