0

When I write this n=(2*100)/3; its actual ans is 66.66667 but it shows 66.00000 why it is? And how I fix it to show exact value?

4th Apr 2020, 9:48 AM
Aditya Chandrikapure
Aditya Chandrikapure - avatar
8 ответов
+ 2
(2*100)/3 is evaluates as integer division because its operands are both int. you should use (2*100)/3.0 or (2.0*100)/3
4th Apr 2020, 10:16 AM
andriy kan
andriy kan - avatar
+ 1
C language
4th Apr 2020, 9:57 AM
Aditya Chandrikapure
Aditya Chandrikapure - avatar
0
Aditya Chandrikapure Which language are you using? please add tag to get correct person to help you
4th Apr 2020, 9:57 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
What I do for this? If you know please help me
4th Apr 2020, 9:59 AM
Aditya Chandrikapure
Aditya Chandrikapure - avatar
0
I don't know C, but would guess it is caused by the program interpreting your request as an integer intput, instead of a float input
4th Apr 2020, 10:00 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Aditya Chandrikapure Update your post with a tag showing the C language
4th Apr 2020, 10:02 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
I take n as float not an int
4th Apr 2020, 10:02 AM
Aditya Chandrikapure
Aditya Chandrikapure - avatar
0
Aditya Chandrikapure i dont know whic language are u using but answer in python3 is absolutely correct.
4th Apr 2020, 9:12 PM
Tarun
Tarun - avatar