+ 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
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;