Computational constructsArithmetic operators (performing calculations)

Programs run in sequences. Selection statements and loops are used in programs, allowing software to make decisions and repeat actions. These are called computational constructs

Part ofComputing ScienceSoftware design and development

Arithmetic operators (performing calculations)

To perform calculations, computer programmers use arithmetic operators.

Here are some examples of calculations using arithmetic operators and variables:

Add
SET total TO a+b
Adding the value of variable a to the value of variable called b. So if a contained 6 and b contained 2, the value 8 would be assigned to the total variable.
Subtract
SET total TO a-b
Subtracting the value of variable b from the value of variable called a. So if a contained 6 and b contained 2, the value 4 would be assigned to the total variable.
Multiply
SET total TO a*b
Multiplying the value of variable a with the value of variable b. So if a contained 6 and b contained 2, the value 12 would be assigned to the total variable.
Divide
SET total TO a/b
Dividing the value of variable a with the value of variable b. So if a contained 6 and b contained 2, the value 3 would be assigned to the total variable.
Exponent
SET total TO a^b
Raises the value of variable a to the value of variable b. So if a contained 6 and b contained 2, the value of 62 would be assigned to the total variable. In this case 62 is 36, so the value 36 is assigned to the total variable.
Add
SET total TO a+b
Adding the value of variable a to the value of variable called b. So if a contained 6 and b contained 2, the value 8 would be assigned to the total variable.
Subtract
SET total TO a-b
Subtracting the value of variable b from the value of variable called a. So if a contained 6 and b contained 2, the value 4 would be assigned to the total variable.
Multiply
SET total TO a*b
Multiplying the value of variable a with the value of variable b. So if a contained 6 and b contained 2, the value 12 would be assigned to the total variable.
Divide
SET total TO a/b
Dividing the value of variable a with the value of variable b. So if a contained 6 and b contained 2, the value 3 would be assigned to the total variable.
Exponent
SET total TO a^b
Raises the value of variable a to the value of variable b. So if a contained 6 and b contained 2, the value of 62 would be assigned to the total variable. In this case 62 is 36, so the value 36 is assigned to the total variable.