6/2%2=1 ,please explain. I don't understand how they get 1? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

6/2%2=1 ,please explain. I don't understand how they get 1?

11th Nov 2016, 3:45 AM
Joemyr Ayen Ramos
Joemyr Ayen Ramos - avatar
3 Answers
+ 3
what happened here is '/' has higher precedence over '%' so it first computes 6/2=3 and then it computes 3%2 will give us 1. This is how precedence rule.
11th Nov 2016, 4:01 AM
Vishal Koshti
Vishal Koshti - avatar
+ 3
because of operator precedence. 6/2%2 =3%2 =1
11th Nov 2016, 8:42 AM
Harish Nandoliya
Harish Nandoliya - avatar
+ 2
it is very easy unless you don't know about reminder sign. 6/2=3 and 3%2=1. reminder of 3/2 is 1. Thee sign % represent reminder.
11th Nov 2016, 4:02 AM
Md Mizanur Rahman
Md Mizanur Rahman - avatar