The Arduino programming language includes operators that enable us to calculate the sum, difference, product and quotient of two operands. To use these operators, the two operands must be of the same type. This means, as an example, we have the ability to calculate the sum of two integer variables; however, we are unable to calculate the sum of a float variable and an integer variable without casting one of the variables forcing them to be of the same type. We will look at casting a little later in this chapter.
The following example shows how we calculate the sum, difference, product, and quotient of two variables:
z = x + y; // calculates the sum of x and y z = x - y; // calculates the difference of x and y z = x * y; // calculates the product of x and y z = x / y; // calculates the quotient of x and y
When we perform a division operation there are times...