Unit 9 Key Programming Concepts: Homework 1 Data Types and Operations
Unit 9 Key Programming Concepts: Homework 1 Data Types and Operations
1. State the values of a, b, c, d and e after the following operations are carried out: [5]
(c) c ← (7 + 3) * 4 – 1 ______________________________________________________
2. The following table shows a number of different variables and what they are used for.
Complete the table to suggest appropriate data types for each of the variables. The first row
has been completed for you.
1
Homework 1 Data types and operations
Unit 9 Key programming concepts
3. The function CHAR_TO_CODE('a') evaluates to 97, the ASCII value of the character ‘a’.
CODE_TO_CHAR(97) evaluates to 'a'.
State what is output by this algorithm: [4]
x ← CHAR_TO_CODE('b') ________________________________________________
y←x+1 ________________________________________________
z←x–1 ________________________________________________
w ← CODE_TO_CHAR(y) + CODE_TO_CHAR(z)_________________________________
OUTPUT x ________________________________________________
OUTPUT y ________________________________________________
OUTPUT z ________________________________________________
OUTPUT w ________________________________________________
[Total 12 marks]