First, you are performing operations with a and b before they have been initialized. They could be junk, they could be 0, they could be anything at all.
Apart from that: you are performing integer division. Even though you are storing the result in a double, the actual division is done with integer values, which means that the remainder is simply thrown away. This means that you should have 0 (as 2 / 4 = 0.5, but you throw away the remainder, hence 0).
Also, you are misunderstanding how the modulo operator works. It gets one number, and returns the remainder when you divide it by a second number. Hence 2 % 4 = 2, because 2 / 4 = 0 remainder 2.