0

Pls i don't understand how the answer of the question is 4?

var b=5; var a=20; a++; a--; var c =b % a; alert (c);

11th May 2019, 1:08 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
7 Respostas
+ 6
var b=5; var a=20; a++; b--; // a = 21, b = 4 var c =b % a; // c = 4 % 21 alert (c); // 4 4 % 21 (modulo division): 21 goes into 4 0 times, there will be a remainder of 4
11th May 2019, 1:43 PM
Anna
Anna - avatar
+ 4
It isn't?! The answer of this will be 5... 5%20=5 It can be 4 if you do b-- instead of a--
11th May 2019, 1:14 PM
Kartik
Kartik - avatar
+ 3
Definitely 5 Check it for yourself https://code.sololearn.com/WBvF8m20vt3J/?ref=app
11th May 2019, 1:17 PM
Kartik
Kartik - avatar
+ 1
Oh, i am sorry for the mistake, in place of a--, it is b--
11th May 2019, 1:19 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
+ 1
Thanks, gotten
11th May 2019, 1:45 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
0
I ran it in my text editor and the answer is 4
11th May 2019, 1:15 PM
Bolaji Olayinka
Bolaji Olayinka - avatar
0
Pls can u explain the process
11th May 2019, 1:23 PM
Bolaji Olayinka
Bolaji Olayinka - avatar