1.25%0.5 give the output. . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

1.25%0.5 give the output. .

29th Jun 2019, 6:06 PM
Udhab Mandal
Udhab Mandal - avatar
15 Answers
+ 2
1.25 % 0.5 = 0.25 Because 1.25 / 0.5 = 2 And 1.25 - 0.5 * 2 = 0.25
29th Jun 2019, 8:13 PM
Seb TheS
Seb TheS - avatar
+ 1
0.25. % is the remainder (or modulus) operation, it divides the 2 numbers and gives the remainder
29th Jun 2019, 6:19 PM
Airree
Airree - avatar
+ 1
How?
29th Jun 2019, 6:21 PM
Udhab Mandal
Udhab Mandal - avatar
+ 1
It must be 0.
29th Jun 2019, 6:21 PM
Udhab Mandal
Udhab Mandal - avatar
+ 1
No.
29th Jun 2019, 6:21 PM
Airree
Airree - avatar
+ 1
Why?
29th Jun 2019, 6:22 PM
Udhab Mandal
Udhab Mandal - avatar
+ 1
I just explained.
29th Jun 2019, 6:22 PM
Airree
Airree - avatar
+ 1
How ?there must be no remainder
29th Jun 2019, 6:23 PM
Udhab Mandal
Udhab Mandal - avatar
+ 1
1.25 / 0.5 equals 2. 1.25 - (2 * 0.5) equals 0.25.
29th Jun 2019, 6:24 PM
Airree
Airree - avatar
+ 1
I m not able to understand it
29th Jun 2019, 6:27 PM
Udhab Mandal
Udhab Mandal - avatar
+ 1
Well, it is 3rd grade math. You will subtract 0.5 from 1.25 until you reach 0. 1.25 - 0.5 = 0.75, 0.75 - 0.5 = 0.25. You can't go further, so the remainder is 0.25
29th Jun 2019, 6:29 PM
Airree
Airree - avatar
+ 1
In your particular case the Modulus operation checks how often 0.5 fits into 1.25 as Airree said. It fits in 2 times (2 * 0.5 = 1.0) and 0.25 are remaining
29th Jun 2019, 6:30 PM
ChrA
ChrA - avatar
+ 1
Can't we go for 125/50?
29th Jun 2019, 6:34 PM
Udhab Mandal
Udhab Mandal - avatar
+ 1
125/50 would do 2.5 125%50 will result in 25
29th Jun 2019, 6:34 PM
ChrA
ChrA - avatar
+ 1
Can't we go for normal division here?
29th Jun 2019, 6:36 PM
Udhab Mandal
Udhab Mandal - avatar