Arithmetic Operators and Expressions

Calculate what the school report needs

A teacher has marks of 40 and 35 out of 50. A report needs their total and average. A sports organizer also needs to know how many students remain after forming teams of four.

An arithmetic operator calculates using numeric values. An expression combines values and operators to produce another value; storing or displaying it is a separate action.

  1. Calculate

    Choose addition, subtraction, multiplication or division for a school task.

  2. Group operations

    Explain why parentheses change an average calculation.

  3. Interpret remainder

    Find leftover students without treating % as a percentage.

An average needs a total first

  1. Read marks

    Two subject values are available.

    40 and 35
  2. Add

    Compute the combined mark.

    40 + 35 = 75
  3. Divide

    Share the total across two subjects.

    75 / 2 = 37.5
Read these stages alongside the complete example. They explain the relationship; they do not execute code.

Choose an operation by its meaning

+ adds quantities, - subtracts, * multiplies, and / divides. The values being operated on are called operands. In maths + science, both marks are operands.

Multiplication and division bind more tightly than addition and subtraction. Parentheses explicitly group the work you want done first. They are particularly useful when a formula combines a total with division.

Before starting, review converting and validating numeric input. These examples use JavaScript; other languages can use different syntax and rules.

Compare two ways to write an average

In this JavaScript program, the first output divides science by two before adding maths: 35 / 2 = 17.5, then 40 + 17.5 = 57.5.

The second groups both marks first: 40 + 35 = 75, then 75 / 2 = 37.5. The program follows the expression exactly; it does not infer that both lines were meant to be averages.

JavaScript · local teaching example

const maths = 40;
const science = 35;
console.log(maths + science / 2);
console.log((maths + science) / 2);

Expected output

57.5
37.5

Form teams and count the leftovers

The remainder operator % gives what remains after division. With 10 students and teams of four, two teams use eight students and two students remain. It does not calculate a percentage.

JavaScript / can produce a fraction. Math.floor rounds downward, so the first output below counts complete teams for these nonnegative quantities. Python has // for floor division; do not assume JavaScript uses that syntax.

JavaScript · local teaching example

const students = 10;
const teamSize = 4;
console.log(Math.floor(students / teamSize));
console.log(students % teamSize);

Expected output

2
2

Repeat multiplication with a power

JavaScript ** raises a number to a power. For a square school garden with side length 6 metres, 6 squared is 36 square metres. This is not the same as doubling six.

Use a power only when it matches the quantity you are calculating; the unit of area differs from the unit of length.

JavaScript · local teaching example

const sideLength = 6;
console.log(sideLength ** 2);
console.log(sideLength * 2);

Expected output

36
12

Apply the rule to a small change

A third subject has mark 25. Write the total and the average over all three subjects. Predict both outputs before reading the answer.

Worked answer

The total is 100. Divide that whole total by 3, not just the English mark. The result is approximately 33.3333; the output below shows JavaScript’s numeric representation.

JavaScript · local teaching example

const maths = 40;
const science = 35;
const english = 25;
const total = maths + science + english;
console.log(total);
console.log(total / 3);

Expected output

100
33.333333333333336

Recognize mistakes and limits

Do not calculate an average with a zero subject count. JavaScript numeric division by zero can yield Infinity, and 0 / 0 yields NaN; neither is a usable school average. Check the denominator deliberately.

Ordinary JavaScript Number arithmetic can have rounding differences for decimal fractions. Choose a deliberate representation and rounding policy for exact amounts. Also remember that + can join strings; validate and convert text input before arithmetic.

For the language or tool rules used here, see JavaScript operator rules.

Check the core idea

JavaScript · code for this question

const maths = 40;
const science = 35;
console.log(maths + science / 2);
console.log((maths + science) / 2);
Why does the displayed average program need parentheses?
Choose one answer. You can try again.

Answer and explanation

They ensure both marks are added before dividing the total.

Yes. Without grouping, division applies to science first.

Apply the idea to a new situation

What does 10 % 4 mean when forming teams of four?
Choose one answer. You can try again.

Answer and explanation

Two students remain after complete teams are formed.

Yes. Ten is 2 × 4 plus a remainder of 2.

Translate the task into a grouped calculation

An expression produces a value. Select operators according to the task, and use parentheses to make the intended grouping clear. Remainder counts what is left; division may produce a fractional result.

Explain how you would compute an average over three subjects and why team leftovers require remainder.

Connect this idea with comparing calculated values and numeric representation limits.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: Comparison Operators: Equality and Ordering →