Answer
Flashcards · 2210 · Topic 8
Programming flashcards
11 cards on Topic 8. Pick a subtopic or study them all.
Study mode needs JavaScript. Every card is listed below, so you can still cover the answers and test yourself.
Choose your cards
Session complete
Worth another look:
All 11 cards
For a quick read-through or printing. Cover the right-hand side to test yourself.
Topic 8: Programming
- Which data type should store a postcode, a price and a yes/no answer?
- Postcode: STRING (letters and digits, not used in calculations). Price: REAL. Yes/no answer: BOOLEAN.
- How do you declare a variable and assign a value in Cambridge pseudocode?
- DECLARE Total : INTEGER declares it; Total ← 0 assigns a value using the arrow. The = sign is used only for comparison.
- What are DIV(47, 6) and MOD(47, 6)?
- DIV(47, 6) = 7, the whole-number part of the division. MOD(47, 6) = 5, the remainder, because 47 = 6 × 7 + 5.
- How do you output an average rounded to 2 decimal places in pseudocode?
- Put the calculation inside ROUND with 2 as the second parameter, e.g. OUTPUT ROUND(Total / Count, 2).
- Where does a string start in Cambridge pseudocode, and what is SUBSTRING("KX4829", 3, 2)?
- The first character is at position 1. SUBSTRING("KX4829", 3, 2) starts at character 3 and takes 2 characters, giving "48".
- How are a function and a procedure called differently?
- A function returns a value, so it is used in an expression, e.g. OUTPUT Perimeter(4.5, 3.0). A procedure does not return a value and is run with CALL.
- Which loop always runs at least once?
- The post-condition loop, REPEAT ... UNTIL, because the condition is tested after each iteration. A WHILE loop tests first and may not run at all.
- What is a CASE OF statement used for?
- Selection between several values of one variable, each with its own action, ending with an optional OTHERWISE and ENDCASE. It is neater than many nested IF statements.
- What is a one-dimensional array?
- A data structure holding several items of the same data type under one identifier, each reached by an index, e.g. DECLARE Scores : ARRAY[1:25] OF INTEGER.
- Why must a program close a file after using it?
- To make sure all data is written to the file and to free it for other use.
- What is a library routine? Give two examples
- A ready-written, tested routine supplied with the language, so you do not write it yourself. Examples: ROUND, RANDOM, MOD, DIV.