COS1511 EXAM PACK
2025
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|50013335
COS1511/201/1/2020
Tutorial letter
Introduction to Programming I
COS1511
Semester 1
School of Computing
This tutorial letter contains the discussion of the solutions to assignment 3 semester 2.
, lOMoARcPSD|50013335
COS1511/201
Question 1
Which of the following is a valid variable name?
1. sixty_four
2. 64set
3. 6_set
4. dollar$
Correct option: 1
Options 2 and 3 are incorrect because a variable name cannot start with a numerical value.
Option 4 is incorrect because a variable name may not contain an ampersand character.
Question 2
Which of the following is not a valid variable name?
1. myInt
2. myDouble
3. sumOf4
4. return
Correct option: 4
Options 4 is correct as return is a reserved word in C++ and cannot be used as a variable name.
Options 1, 2 and 3 are all valid variable names.
2
2
, lOMoARcPSD|50013335
COS1511/201
Question 3
What is the value of xafter the following statements?
int x, y, z;
y = 10;
z = 3;
x = y * z - 3;
1. 0
2. 3
3. 10
4. 27
Correct option: 4
Options 4 is correct as *has precedence over +:
x = y * z - 3
x = 10 * 3 - 3
x = 30 - 3
x = 27
You can also include brackets for easier readability:
x = (y * z) - 3
x = (10 * 3) - 3
x = 30 - 3
x = 27
Question 4
What is the value of xafter the following statements?
int x;
x = 0;
x = x * 13;
1. 0
2. 13
3. 34
4. not defined
Correct option: 1
Options 2 is correct as the integer value 0is assigned to xand thus it is addition between two integer values.
x = x * 30
x = 0 * 30
x = 0
3
3
2025
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|50013335
COS1511/201/1/2020
Tutorial letter
Introduction to Programming I
COS1511
Semester 1
School of Computing
This tutorial letter contains the discussion of the solutions to assignment 3 semester 2.
, lOMoARcPSD|50013335
COS1511/201
Question 1
Which of the following is a valid variable name?
1. sixty_four
2. 64set
3. 6_set
4. dollar$
Correct option: 1
Options 2 and 3 are incorrect because a variable name cannot start with a numerical value.
Option 4 is incorrect because a variable name may not contain an ampersand character.
Question 2
Which of the following is not a valid variable name?
1. myInt
2. myDouble
3. sumOf4
4. return
Correct option: 4
Options 4 is correct as return is a reserved word in C++ and cannot be used as a variable name.
Options 1, 2 and 3 are all valid variable names.
2
2
, lOMoARcPSD|50013335
COS1511/201
Question 3
What is the value of xafter the following statements?
int x, y, z;
y = 10;
z = 3;
x = y * z - 3;
1. 0
2. 3
3. 10
4. 27
Correct option: 4
Options 4 is correct as *has precedence over +:
x = y * z - 3
x = 10 * 3 - 3
x = 30 - 3
x = 27
You can also include brackets for easier readability:
x = (y * z) - 3
x = (10 * 3) - 3
x = 30 - 3
x = 27
Question 4
What is the value of xafter the following statements?
int x;
x = 0;
x = x * 13;
1. 0
2. 13
3. 34
4. not defined
Correct option: 1
Options 2 is correct as the integer value 0is assigned to xand thus it is addition between two integer values.
x = x * 30
x = 0 * 30
x = 0
3
3