Docsity

Exam 02: Number Systems and Data Representation, Exams of Computer Programming

Toggle sidebar
bg1
Exam 02: Number Systems and Data Representation Page 1
Exam 02: Number Systems and Data
Representation
Computer Science Exam Series | Time: 2 hours | Total: 84 marks
Answer all questions. Part A has 50 multiple choice questions (1 mark each). Part B has 8 short
answer questions (3 marks each). Part C has 2 longer questions (5 marks each). In Part A the
correct option is marked with a double tick. Calculators are not allowed. Answer key and model
answers are at the end.
Part A: Multiple Choice (50 marks)
Q1. How many different digits does the binary number system use?
a) 2 โœ”โœ”
b) 8
c) 10
d) 16
Q2. What is the decimal value of binary 1010?
a) 8
b) 10 โœ”โœ”
c) 12
d) 5
Q3. What is the decimal value of binary 1111?
a) 14
b) 16
c) 15 โœ”โœ”
d) 17
Q4. What is the decimal value of binary 10000?
a) 8
b) 16 โœ”โœ”
c) 32
d) 10
Q5. What is the decimal value of binary 11001?
a) 25 โœ”โœ”
b) 19
c) 21
d) 27
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Exam 02: Number Systems and Data Representation and more Exams Computer Programming in PDF only on Docsity!

Exam 02: Number Systems and Data

Representation

Computer Science Exam Series | Time: 2 hours | Total: 84 marks

Answer all questions. Part A has 50 multiple choice questions (1 mark each). Part B has 8 short answer questions (3 marks each). Part C has 2 longer questions (5 marks each). In Part A the correct option is marked with a double tick. Calculators are not allowed. Answer key and model answers are at the end.

Part A: Multiple Choice (50 marks)

Q1. How many different digits does the binary number system use?

a) 2 โœ”โœ” b) 8 c) 10 d) 16

Q2. What is the decimal value of binary 1010?

a) 8 b) 10 โœ”โœ” c) 12 d) 5

Q3. What is the decimal value of binary 1111?

a) 14 b) 16 c) 15 โœ”โœ” d) 17

Q4. What is the decimal value of binary 10000?

a) 8 b) 16 โœ”โœ” c) 32 d) 10

Q5. What is the decimal value of binary 11001?

a) 25 โœ”โœ” b) 19 c) 21 d) 27

Q6. What is the decimal value of binary 101101?

a) 43 b) 47 c) 45 โœ”โœ” d) 41

Q7. What is the decimal value of the 8-bit binary number 11111111?

a) 128 b) 255 โœ”โœ” c) 256 d) 127

Q8. What is decimal 7 in binary?

a) 101 b) 110 c) 111 โœ”โœ” d) 1000

Q9. What is decimal 20 in binary?

a) 10010 b) 10100 โœ”โœ” c) 10110 d) 11000

Q10. What is decimal 37 in binary?

a) 100101 โœ”โœ” b) 101001 c) 100011 d) 110001

Q11. What is decimal 100 in binary?

a) 1010100 b) 1101100 c) 1100010 d) 1100100 โœ”โœ”

Q12. What is the decimal value of hexadecimal A?

a) 9 b) 10 โœ”โœ” c) 11 d) 12

Q20. What is binary 11110000 in hexadecimal?

a) 0F b) F0 โœ”โœ” c) E d) FF

Q21. What is binary 10101100 in hexadecimal?

a) CA b) A c) AC โœ”โœ” d) BC

Q22. What is hexadecimal 3C in binary?

a) 00111100 โœ”โœ” b) 11000011 c) 00110011 d) 01111000

Q23. Why is hexadecimal commonly used by programmers?

a) Computers can only process hexadecimal b) It is a compact, human-friendly way to write binary โœ”โœ” c) It executes faster than binary d) It uses fewer transistors

Q24. What is the decimal value of octal 17?

a) 17 b) 14 c) 15 โœ”โœ” d) 13

Q25. What is decimal 8 in octal?

a) 8 b) 7 c) 10 โœ”โœ” d) 80

Q26. What is binary 101110 in octal?

a) 56 โœ”โœ” b) 46 c) 65 d) 35

Q27. What is binary 101 + 011?

a) 1000 โœ”โœ” b) 110 c) 1010 d) 111

Q28. What is binary 1111 + 1?

a) 1110 b) 10000 โœ”โœ” c) 11111 d) 10001

Q29. What is binary 1101 + 1011?

a) 11000 โœ”โœ” b) 10110 c) 11100 d) 10111

Q30. What happens when 1 is added to the 8-bit unsigned value 255?

a) The result 256 is stored correctly b) Overflow occurs and the value wraps around to 0 โœ”โœ” c) The result becomes 128 d) The result becomes 511

Q31. What is the range of an 8-bit unsigned integer?

a) 0 to 127 b) 0 to 255 โœ”โœ” c) -128 to 127 d) 1 to 256

Q32. What is the range of an 8-bit two's complement integer?

a) -127 to 127 b) -128 to 127 โœ”โœ” c) 0 to 255 d) -256 to 255

Q33. What is the range of an 8-bit sign-and-magnitude integer?

a) -127 to 127 โœ”โœ” b) -128 to 127 c) 0 to 255 d) -255 to 255

Q41. What is the ASCII code, in decimal, of the capital letter A?

a) 64 b) 65 โœ”โœ” c) 97 d) 66

Q42. What is the difference between the ASCII codes of "a" and "A"?

a) 1 b) 16 c) 32 โœ”โœ” d) 26

Q43. How many characters can standard 7-bit ASCII represent?

a) 256 b) 128 โœ”โœ” c) 64 d) 1024

Q44. What is the main purpose of Unicode?

a) To compress files b) To represent characters from most of the world's writing systems โœ”โœ” c) To encrypt text d) To store images

Q45. An image is 100 pixels wide and 100 pixels high with 8 bits per pixel. What is its size in bytes (ignoring headers)?

a) 10,000 โœ”โœ” b) 80, c) 800 d) 100

Q46. How many different colours can an 8-bit colour depth represent?

a) 8 b) 64 c) 256 โœ”โœ” d) 65,

Q47. How many bytes per pixel does 24-bit colour use?

a) 1 b) 2 c) 3 โœ”โœ” d) 4

Q48. What is the even parity bit for the 7-bit pattern 1011001?

a) 1 b) 0 โœ”โœ” c) It cannot be determined d) 2

Q49. What is the result of shifting 00000011 one place to the left?

a) 00000001 b) 00000110 โœ”โœ” c) 00001100 d) 00000011

Q50. A floating-point number is stored using:

a) Only whole numbers b) A mantissa and an exponent โœ”โœ” c) Text characters d) Image pixels

Part B: Short Answer (24 marks)

S1. Convert decimal 45 to binary and to hexadecimal. [3]

S2. Explain what two's complement is and why it is used to store negative integers. [3]

S3. Explain what overflow is, using an 8-bit unsigned example. [3]

S4. State two differences between ASCII and Unicode. [3]

S5. Explain why computers use binary rather than decimal. [3]

S6. Explain how a bitmap image is stored and how colour depth and resolution affect file size. [3]

Answer Key: Part A

Q Answer Q Answer Q Answer Q Answer Q Answer 1 a 11 d 21 c 31 b 41 b 2 b 12 b 22 a 32 b 42 c 3 c 13 c 23 b 33 a 43 b 4 b 14 d 24 c 34 b 44 b 5 a 15 a 25 c 35 c 45 a 6 c 16 b 26 a 36 a 46 c 7 b 17 c 27 a 37 b 47 c 8 c 18 c 28 b 38 b 48 b 9 b 19 a 29 a 39 c 49 b 10 a 20 b 30 b 40 b 50 b

Model Answers: Parts B and C

S1. 45 = 32 + 8 + 4 + 1, so binary is 101101 (1 mark). Group in fours as 0010 1101 (1 mark), giving hexadecimal 2D (1 mark). โœ”โœ” S2. Two's complement represents a negative number by inverting all the bits of its positive value and adding 1 (1 mark). It gives a single representation of zero (1 mark). Addition and subtraction can use the same circuits for positive and negative numbers (1 mark). โœ”โœ” S3. Overflow occurs when the result of a calculation is too large to fit in the available number of bits (1 mark). For example 255 + 1 needs 9 bits (100000000) but only 8 are available (1 mark). The extra bit is lost, so the stored result is 00000000, which is wrong (1 mark). โœ”โœ” S4. ASCII uses 7 bits per character (128 characters) while Unicode uses more bits such as 8 to 32 in UTF-8 (1 mark). ASCII covers mainly English letters, digits and symbols, while Unicode covers most world languages, symbols and emoji (1 mark). ASCII codes are a subset of Unicode, so Unicode is backward compatible (1 mark). โœ”โœ” S5. Digital circuits are built from transistors that have two states, on and off (1 mark). Two states are easy to represent reliably with two voltage levels (1 mark). They are less prone to errors caused by noise than circuits distinguishing ten levels (1 mark). โœ”โœ” S6. A bitmap is stored as a grid of pixels, each with a binary value for its colour (1 mark). Greater colour depth means more bits per pixel, so the file is larger (1 mark). Higher resolution means more pixels, so the file is also larger (1 mark). โœ”โœ” S7. 7E = 7 x 16 + 14 = 126 (1 mark for method, 1 mark for the answer). In binary 7 = 0111 and E = 1110, so 01111110 (1 mark). โœ”โœ” S8. Floating-point numbers store fractions in binary (1 mark). 0.1 in binary is a repeating fraction that never terminates (1 mark). It must be rounded to fit the available bits, so small rounding errors occur (1 mark). โœ”โœ”

L1. 156 = 128 + 16 + 8 + 4, so binary is 10011100 (2 marks). Grouping in fours: 1001 1100 gives hexadecimal 9C (2 marks). Grouping in threes from the right: 010 011 100 gives octal 234 ( mark). Check: 2 x 64 + 3 x 8 + 4 = 156. โœ”โœ”

L2. 45 = 00101101 (1 mark). Invert the bits: 11010010 (1 mark). Add 1 to get 11010011, which is -45 (1 mark). +20 = 00010100. The sum 11010011 + 00010100 = 11100111 (1 mark). To read the result, invert 00011000 and add 1 to get 00011001 = 25, so the value is -25, which equals -45 + 20 (1 mark). โœ”โœ”