## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Arithmetic functions

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 * ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required