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 →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Astronomy & Space Science
  • Earth & Environmental 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. Quizzes
  2. /An array is written to a file backwards. What is output?
Computer ScienceHardHigh School (9–10)Algorithms, Programming and Logic › ProgrammingIGCSE
StemPy LabCreated by StemPy Lab
Read about Programming first

Programming is writing instructions that a computer can carry out. This topic covers the building blocks found in every language. Variables and constants store data of a type such as integer, real, string or Boolean. Sequence, selection and iteration control the order of steps: IF statements choose, and FOR, WHILE and REPEAT loops repeat. Arrays hold lists of values, and procedures and functions break a long program into parts. Programs also validate input, handle strings and read and write files. You practise these in pseudocode and in Python.

Lessons, worked problems and more questions on Programming →

An array is written to a file backwards. DECLARE Words : ARRAY[1:3] OF STRING DECLARE i : INTEGER DECLARE Top : STRING Words[1] ← "red" Words[2] ← "amber" Words[3] ← "green" OPENFILE "Lights.txt" FOR WRITE FOR i ← 3 TO 1 STEP -1 WRITEFILE "Lights.txt", Words[i] NEXT i CLOSEFILE "Lights.txt" OPENFILE "Lights.txt" FOR READ READFILE "Lights.txt", Top CLOSEFILE "Lights.txt" OUTPUT Top What is output?

The loop writes green first, then amber, then red. The first READFILE reads the first line written: green. red is the first element of the array, but it was written last. amber is the middle line. One READFILE reads one line only.
Log in to save
← All Quizzes
← The file Times.txt holds four lines: 48, 73, 50 and 91. What is output?Five bins stand in a row. Each bin takes the load of the bin behind it. What is output? →
More onAlgorithms, Programming and Logic › Programming

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. Five bins stand in a row. Each bin takes the load of the bin behind it. What is output?Hard
  2. The file Times.txt holds four lines: 48, 73, 50 and 91. What is output?Hard
  3. A small hall has 3 rows of 3 chairs, numbered 1 to 9 from the front left. The numbers are kept in…Hard
  4. Five children are measured. The program looks for the position of the tallest, with >= in its…Hard
  5. A shelf holds three jars, and an array keeps their masses in grams. The first and the last jar…Medium
All questions on this topic →

Problems 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
  4. 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
All problems on this topic →