0

What is a= -12%10 in C?

11th Jun 2018, 11:39 AM
Dhanaraj S
Dhanaraj S - avatar
3 odpowiedzi
+ 3
Plus hinanawi 's comment, if you find the left hand operand negative (e.g. -x % y or -x % -y), the result is going to be negative unless the result is 0. The sign of the right hand operand has no effect on the operation.
11th Jun 2018, 2:55 PM
Babak
Babak - avatar
+ 6
Well, you can try it on code playground
11th Jun 2018, 11:41 AM
Sachin Artani
Sachin Artani - avatar
0
that would be -2 my friend. "%" is the modulo operator and it returns the remainder when dividing the first number with the second. -12 / 10 = -1 with the remainder -2. (-12 = -10*1 + (-2))
11th Jun 2018, 2:16 PM
hinanawi
hinanawi - avatar