HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /Three teams play three games each. Points[Team, Game] holds the points of a team in a game…
MediumComputer ScienceHigh School (9–10)Computer Science › ProgrammingNumericalIGCSE

Three teams play three games each. Points[Team, Game] holds the points of a team in a game…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

Three teams play three games each. Points[Team, Game] holds the points of a team in a game. The nine inputs, row by row, are 3, 1, 0, then 0, 3, 1, then 1, 1, 3.

pseudocode
DECLARE Points : ARRAY[1:3, 1:3] OF INTEGER
DECLARE Team : INTEGER
DECLARE Game : INTEGER
DECLARE Sum : INTEGER
FOR Team ← 1 TO 3
    FOR Game ← 1 TO 3
        INPUT Points[Team, Game]
    NEXT Game
NEXT Team
FOR Game ← 1 TO 3
    Sum ← 0
    FOR Team ← 1 TO 3
        Sum ← Sum + Points[Team, Game]
    NEXT Team
    OUTPUT Sum
NEXT Game

What are the three outputs? Are they row totals or column totals?

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

DECLARE Name : ARRAY[1:Rows, 1:Columns] OF TYPE has rows times columns elements. An element is Name[Row, Column]. Nested loops visit every element: the outer loop for the rows, the inner loop for the columns. A row total is set to zero inside the outer loop, before the inner one.

The worked solution

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Step 1. The table. Team 1 scored 3, 1, 0; team 2 scored 0, 3, 1; team 3 scored 1, 1, 3.

Step 2. The totals. The outer loop is over Game, so each total is a column total:

  • game 1: 3+0+1=43 + 0 + 1 = 43+0+1=4;
  • game 2: 1+3+1=51 + 3 + 1 = 51+3+1=5;
  • game 3: 0+1+3=40 + 1 + 3 = 40+1+3=4.

Answer: 4, 5 and 4, the column totals.

Check. The three outputs add up to 13, the total of all nine inputs. Row totals would be 4, 4 and 5, which also add up to 13, so check the order too.

Log in to save this for later
← All Problems
← A small theatre has 5 rows of 8 seats. The program marks booked seats…The nine squares of a board are input row by row: X, O, O, then X, X, X, then O, a dot for an empty… →
More onComputer Science › Programming

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Two-dimensional arrays and nested loopsArrays and Files in Pseudocode

More on this topic

  1. A long scenario question. A teacher has the names of 5 students in the file Names.txt, one name a…Hard
  2. Shopping.txt holds six lines: bread, rice, milk, eggs, tea and jam…Medium
  3. The file Best.txt holds one line: 120. What is output, and what does Best.txt hold afterwards, when…Easy
The nine squares of a board are input row by row: X, O, O, then X, X, X, then O, a dot for an empty…Hard
  • A small theatre has 5 rows of 8 seats. The program marks booked seats…Easy
  • All problems on this topic →