var a = 5;
var b = 2;
var c = a % b;
//comment: with arithmetic, the division of two integers produces a quotient and a remainder.
//However with mathematics, the result of a modulo operation is the remainder of an arithmetic division.
As you learned at school, the multiplication is done first
Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-).
And (as you have learned in school) the precedence can be changed by using parentheses as we show below:
var a = (5 + 5) * 2;
While using parentheses, the operations inside the parentheses are computed first.
While many operations have the same precedence (like addition and subtraction), they will be computed from left to right:
Learn to code, we offer free programming guides, our main goal is to allow students to learn web development easily from home.