OCR_Computing_GCSE_Programming Flashcards
A syntax error can occur when writing a program.
State what is meant by a syntax error, giving an example.
State :An error in the rules/grammar of the language
Example
In C++
int x = Fred
x is an integer NOT a string
Missing a semicolon too. Sigh!
Describe tools and facilities available in an integrated development environment (IDE) which can help the programmer to identify and correct syntax errors.
Error messages/translator diagnostics produced when translating/by the compiler or on the fly while writing code. (breakpoints)
Attempts to tell you what the error is and indicate where the error is/line numbers/underlines. (auto completion)
Editor allows you to enter the corrected code.
Huzaifa is writing a program which simulates a dice game played with three ordinary 6-sided dice.
When the player rolls the three dice, the player is given points according to the algorithm expressed in the flow diagram (flow chart) below
State the value of the score if the dice rolled are
3 4 5
0
Huzaifa is writing a program which simulates a dice game played with three ordinary 6-sided dice.
When the player rolls the three dice, the player is given points according to the algorithm expressed in the flow diagram (flow chart) below
State the value of the score if the dice rolled are
4 4 4
12
Huzaifa is writing a program which simulates a dice game played with three ordinary 6-sided dice.
When the player rolls the three dice, the player is given points according to the algorithm expressed in the flow diagram (flow chart) below
State the value of the score if the dice rolled are
5 5 6
4
Huzaifa is writing a program which simulates a dice game played with three ordinary 6-sided dice.
When the player rolls the three dice, the player is given points according to the algorithm expressed in the flow diagram (flow chart) below
State a set of three numbers which can be used to test whether the algorithm produces a negative score when it should, and state the expected output for your test data.
Set of test data: 1 1 3 / 1 1 4 / 1 1 5 / 1 1 6 / 2 2 5 / 2 2 6
Expected output: -1 -2 -3 -4 -1 -2
Explain why a program written in a high level language needs to be translated before it can be executed.
High level languages (HLL) are understood by humans. Computers/the CPU can only understand/execute machine code (1 and 0’s) instructions. The translator converts a program in the HLL to an equivalent program in machine code.
A compiler and an interpreter are two different types of translator. Describe differences between a compiler and an interpreter.
A compiler translates the entire program before execution C++
An interpreter translates one line, executes that line and then translates the next line. Python/Javascript
A compiler creates a list of errors after compilation. C++
An interpreter stops after the first error.Python/Javascript
A compiler produces an independent executable file.C++
Interpreted program needs the interpreter each time it is run.
Python/Javascript
A compiled program is translated once..C++
An interpreted program is translated each time it is run.Python/Javascript
When dice are rolled, the results are stored in an array called DiceResult.
For example, if the first dice shows a 5 then the value of DiceResult(1) becomes 5.
Describe what is meant by an array.
A data structure/collection of several variables under one name. Each individual variable is given an index by which it is referred within the array.
The routine for rolling the dice is written as a sequence below.
BEGIN RollTheDice
DiceResult(1) = Random Number between 1 and 6
DiceResult(2) = Random Number between 1 and 6
DiceResult(3) = Random Number between 1 and 6
END
Rewrite this routine so that it uses iteration.
You must use a diagram.
Will also accept similar with FOR-NEXT loop
BEGIN RollTheDice
i = 1
WHILE i <= 3
DiceRoll(i) = Random No
i = i + 1 **END WHILE** END
A mail-order company buys dresses from America and France to sell in the UK. The company uses the following algorithm to convert sizes before printing them in its catalogue. Half sizes are not possible (e.g. size 12.5).
INPUT Size
INPUT Origin
IF Origin = “America” THEN
Size = Size + 2
ELSE
IF Origin = “France” THEN
Size = Size – 26
END IF
END IF
State the size which will be printed in the catalogue using the algorithm given for dress Origin : France Size : 40
14
A mail-order company buys dresses from America and France to sell in the UK. The company uses the following algorithm to convert sizes before printing them in its catalogue. Half sizes are not possible (e.g. size 12.5).
INPUT Size
INPUT Origin
IF Origin = “America” THEN
Size = Size + 2
ELSE
IF Origin = “France” THEN
Size = Size – 26
END IF
END IF
State the size which will be printed in the catalogue using the algorithm given for dress Origin : America Size : 8
10
A mail-order company buys dresses from America and France to sell in the UK. The company uses the following algorithm to convert sizes before printing them in its catalogue. Half sizes are not possible (e.g. size 12.5).
INPUT Size
INPUT Origin
IF Origin = “America” THEN
Size = Size + 2
ELSE
IF Origin = “France” THEN
Size = Size – 26
END IF
END IF
State the size which will be printed in the catalogue using the algorithm given for dress Origin : UK Size : 12
12
Describe what is meant by a variable.
A name/symbol which represents a value is a program. The value can change while the program is running.
A mail-order company buys dresses from America and France to sell in the UK. The company uses an algorithm to convert sizes before printing them in its catalogue.
State the most appropriate data types for the variables Origin and Size, giving a reason for your choice.
ORIGIN
String. Consists of more than one character.
Size
Integer. Consists of whole numbers.
The program in a vending machine uses an array called Coins to store the value in pence of all the coins that have been entered in the current sale.
A maximum of 10 coins can be entered in each sale.
After each sale, the array is reset so that all values are 0.In the example velow, the value of Coins(1) is 10.
[10] [100] [20] [50] [5] [0] [0] [0] [0] [0]
State the value of Coins(4)
50
The program in a vending machine uses an array called Coins to store the value in pence of all the coins that have been entered in the current sale.
A maximum of 10 coins can be entered in each sale.
After each sale, the array is reset so that all values are 0.In the example below, the value of Coins(1) is 10.
[10] [100] [20] [50] [5] [0] [0] [0] [0] [0]
State the value of Coins(10)
0