+ 2

# Difference between '/' and '%' operators??

5 Answers

+ 4

/ is used to get quotient between division e.g. 5/2=2(exact2.5but not displays)
% is used to get remainder e.g. 14%3=2(14/3=4 and remain 2)

+ 2

/ divides and returns that answer.
Example- 10/2=5
% divides and returns the remainder
Example- 13%2=1 because 13 divided by 2 is 6 with a remainder of 1.

+ 2

Try dividing 26 by 6 (without decimals). You know that 24/6=4. But there's still 2 remaining that cannot be divided by 6. (At least without getting decimals) 2 is the modulus

+ 1

To fill in on @animesh answer. if you want to display 2.5 you have to type it like this
a = 5
b = 2
c = (decimal) a / b

+ 1

% operator return remainder.Example 6% 3=0 and 1 % 2 =1. / operator return quotient. Example 6 % 3=2 and 1 / 2=0 and 7 / 3=2.