213 exam-style questions on Programming with answers and explanations. Six real samples below — the full set is free with an account.
A booking system must store a customer telephone number that begins with a zero and is never used in a calculation. Which data type is the most suitable?
Answer: String
Stored as a number the leading zero would be lost and no arithmetic is ever wanted on the value, so the digits are held as characters. A telephone number looks numeric but behaves like text.
A variable is created inside a subprogram and its value is not passed back to the calling code. Which statement about that variable is correct?
Answer: It exists only while the subprogram is running
A local variable is created when the subprogram is entered and destroyed when it ends, so nothing outside can reach it and nothing survives to the next call. That is exactly why the same identifier may be reused safely elsewhere.
A whole number of items is typed at the keyboard and arrives in the variable ENTRY as text. The program must add that number to a running total. What must happen before the addition can be carried out?
Answer: ENTRY must be converted to an integer
Arithmetic needs a numeric type, so the characters have to be converted to an integer before they can be added; joining text to text would only place the digits side by side. Converting the running total to text instead would lose the arithmetic altogether.
A programmer stores the names of a class in an array that is created with 30 places. Which consequence follows directly from the array being a static data structure?
Answer: The number of places is decided when the array is created, so a 31st name cannot be stored.
A static structure fixes its capacity at creation, so the only ways out are to create a larger array and copy, or to choose a dynamic structure. Arrays also store their elements contiguously and hold a single data type, so the other statements describe no array at all.
A print server holds documents until the printer is free and prints them in the order in which they were sent to it. Which data structure models this behaviour?
Answer: A queue, because the item that has waited longest is removed first.
Printing in the order of arrival is first-in first-out, which is exactly the queue rule. A stack would print the newest document first and leave the earliest job waiting indefinitely.
A club stores, for each member, a name (string), a membership number (integer) and whether the fee is paid (Boolean). Which approach keeps the three values of different data types together as one item?
Answer: A record whose named fields hold the three values
A record groups values of different types under named fields, so one member is one item. An array is homogeneous and could not hold a string, an integer and a Boolean, and parallel arrays keep the values in three separate places that must be kept in step by hand.
That was 6 of 213 Programming questions.
Practise all 213 freeOutlineAO1 · 1–2 marks
A brief account or summary: the main points in two or three sentences, no evaluation.
DistinguishAO2 · 2–4 marks
Make the difference clear for BOTH terms — a definition of one of them is only half an answer.
TraceAO2 · 2–4 marks
Follow the algorithm step by step in a trace table, one row per pass, showing every variable that changes.
213 Programming questions — free with an account. Spaced repetition, streaks and full exam simulations included.
Practise them freeThis platform is independently developed and is not endorsed by, affiliated with, or sponsored by the International Baccalaureate Organization. “International Baccalaureate” and “IB” are registered trademarks of the IBO.