Introduction to Programming

Arithmetic Operators

Lesson 5: Arithmetic Operators

What are Arithmetic Operators?

In everyday life, we use math all the time — counting scores, measuring distances, splitting things equally. In programming, we do the same using arithmetic operators. These are special symbols that tell the computer to perform a mathematical operation on two values.

An arithmetic operator is a symbol that performs a mathematical calculation between two values, called operands.

Arithmetic Operators in PictoBlox

PictoBlox provides all the basic arithmetic operators in the Operators palette. Each operator block takes two inputs and returns a result.

Arithmetic Operators in PictoBlox

OperatorSymbolExampleResult
Addition+5 + 38
Subtraction-9 - 45
Multiplication*6 * 318
Division/10 / 25
Modulomod10 mod 31
PictoBlox Operators palette showing arithmetic blocks for addition, subtraction, multiplication, division, and modulo

The Modulo Operator

The modulo operator might be new to you! It returns the remainder after dividing one number by another. For example, 10 mod 3 = 1, because 10 divided by 3 is 3 with a remainder of 1.

The modulo operator is very useful in programming — for example, to check if a number is even or odd. If a number mod 2 = 0, it is even. If it equals 1, it is odd.

Using Arithmetic Operators with Variables

Arithmetic operators become really powerful when combined with variables. You can perform calculations on variable values and store the result back into a variable.

Block coding script showing set Result to the sum of variable A and variable B using an addition operator block
Operator blocks can be nested inside each other to perform complex calculations. For example, you can place an addition block inside a multiplication block!

Subscribe to our newsletter.

Get updates to news and events.