Math operators(+, -, *, /, ^)

This page intoduces the math operators

what does the math operators do? The math operators makes it possible to do math calculations in your code.

how do we use the math operators? You can use the operators to calculate data before giving it to a variable or a function. The method for using the operators while assigning data to a variable is: int x = 1 + 2 - 3 / 4 * a ^ 7; here "int" is used as the variable type. the operators are used to calculate the value assigned to x. "a" refers to the data "a" is storing, which is used in the calculation.

Math operators follow the "order of operations".

Example: int a = 2 / 1; float x = 3 + 5 * a; this line would declare the variable "x" and give it the value 13.

Last updated

Was this helpful?