0

Why my code does not show the value "d" when the decimal point is an exact number?

https://code.sololearn.com/cao0k6bxZcr4/?ref=app https://code.sololearn.com/cao0k6bxZcr4/?ref=app

28th Dec 2020, 11:12 AM
Arash
Arash - avatar
4 Respostas
+ 2
Arash Your code is perfectly fine and the value of d is also working fine . Just split the inputs into multiple lines for eg : 10 % 2 And then submit , you'll get output : 10%2=0 where 0 is the value of variable d .
28th Dec 2020, 11:25 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
Thanhs a lot
28th Dec 2020, 12:11 PM
Arash
Arash - avatar
0
You need to convert <a> to a floating point type before you divide it by 100, otherwise, integer division occurs which gives unexpected results. double d = c * (static_cast<double>(a) / 100);
28th Dec 2020, 11:21 AM
Ipang
0
turn the ints into double
28th Dec 2020, 11:24 AM
Logomonic Learning
Logomonic Learning - avatar