+ 1

Why did this loop execute itslef 5 times?

https://code.sololearn.com/cNKy8KGbEylr/?ref=app Shouldn't it do it 4 times since a=100 and it is supposed to be executed when a<100?

6th May 2020, 3:24 PM
Kamil Kasperek
2 Answers
+ 2
Be cause 0.01 < 100 10*0.01 = 0.1 < 100 10*0.1 = 1 < 100 10*1=10<100 and 10*10 =100 but the incrementation is do after
6th May 2020, 3:33 PM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
+ 1
0.01 ,i=1 0.10,i=2 1,i=3 10,i=4 100 but it's equal to a ,so it should be 4 as you saidđŸ€” float has less precision use double ,
6th May 2020, 3:30 PM
Abhay
Abhay - avatar