Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0478

Use totals and counts together

Accumulate a running total and count how many values contribute to it.

Cambridge IGCSE Computer Science 0478 · Programming · 2026–2028 Version 6 · 8.1
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. It covers section 8.1 (Programming concepts) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding.

Before you begin

  • Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

What should Total usually start as before summing positive values?

What you will learn

  • Initialise a total and counter
  • Update both values for each item
  • Calculate an average only when at least one value exists

A total and a count answer different questions

Total ← Total + Value accumulates the sum. Count ← Count + 1 records how many values have been processed.

Initialise both variables before the loop. Updating the total without the count makes an average impossible; updating the count without the total loses the sum.

Guard the average calculation

Average is Total / Count only when Count > 0. If no values were entered, report that no average is available instead of dividing by zero.

Keep input, update and final output in separate stages so a trace table can show exactly how each value contributes.

Pause and explain

What should a program do if Count is 0 before calculating an average?

Put the idea to work

Worked example

Process scores 6, 8 and 10. Find their total, count and average.

Show the worked solution
  1. Start Total ← 0 and Count ← 0.
  2. For each score, add it to Total and increase Count.
  3. After three scores, Total is 24, Count is 3, and Average is 8.

Answer Total = 24; Count = 3; Average = Total / Count = 8.

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

Three values 4, 7 and 9 are processed. Give final Total, Count and Average.

Give me a hint

Add all values, count each once, then divide.

Compare my reasoning
  1. Total is 4 + 7 + 9 = 20.
  2. Three values were processed.
  3. Average is 20 / 3 = 6.666…

Total = 20; Count = 3; Average = 6.666… (about 6.67).

Look for these in your work

  • Total correct
  • Count correct
  • Mean calculated
2 · Independent

Describe the three updates needed inside a loop to total 8 entered values.

Give me a hint

One value is processed per pass.

Compare my reasoning
  1. Read the next value.
  2. Add it to Total.
  3. Increase Count by one.

Read each value, add it to Total and increment Count, with both variables initialised before the loop.

Look for these in your work

  • Input each pass
  • Total updated
  • Count updated
3 · Transfer

A class has no submitted scores. Explain what an average routine should output and why.

Give me a hint

Check whether any values contributed to the total.

Compare my reasoning
  1. Count remains 0.
  2. Total / Count would divide by zero.
  3. Display a no-scores message instead of a numeric average.

Report that no average is available because there are no scores and division by zero is invalid.

Look for these in your work

  • Zero-count check
  • Safe output

Common mistakes

  • Initialising Total inside the loop
  • Forgetting to increment Count
  • Dividing by zero when no values are present
Recall without your notes

What can you explain now?

Why is Count needed when calculating an average?

Compare with the explanation

It records how many values are in the total

The mean is the total divided by the number of values.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

Why must the average be calculated after the values have been totalled and counted?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 6 syllabus, with worked explanations and guided, independent and transfer practice. This is mapped teaching coverage, not proof of full exam readiness. Three earlier starter lessons remain available but are not counted as syllabus-mapped teaching. Practical programming experience in an executable browser workspace, full timed-paper practice, human subject-teacher review and the separate 2029–2031 syllabus remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.