7/31/23, 5:26 PM Assessment 1: Attempt review
UNISA 2023 INP1501-23-S2 Welcome Message Assessment 1
QUIZ
Started on Monday, 31 July 2023, 4:43 PM
State Finished
Completed on Monday, 31 July 2023, 5:26 PM
Time taken 42 mins 24 secs
Marks 80.00/90.00
Grade 88.89 out of 100.00
Question 1
Correct
Mark 2.00 out of 2.00
What is the value of x after the following statement?
float x;
x = 3..0 + 3 + ;
1. 1.75
2. 3.25
3. 3.75 Correct option: 3
There are two issues to take into consideration.
1. The type of the variable
a. x is declared as a float
b. 2 and 5 is integer values (not 2.0)
c. = 0.4
d. But as it is integer values the result will be 0
2. The order of the operations (p17 of the study guide). In
summary, first * and / and then +
and -. But if the operations are the same – from left to right
3..0 + 3 +
Step 1. 0.75 + 3 +
Step 2. 0.75 + 3 + 0
Step 3. 0.75 + 3
Step 4. 3.75
• In Option 1 ,2 and 4 the calculations are incorrect.
4. 5.75
Your answer is correct.
The correct answer is:
3.75
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 1/32
,7/31/23, 5:26 PM Assessment 1: Attempt review
Question 2
Correct
Mark 2.00 out of 2.00
Which of the following statements is NOT legal?
a. char aChar = 'c';
b. char aChar = '0';
c. char aChar = 65;
d. char Correct option: 4
aChar = • Option 1 is legal, as a character variable named aChar is
"cc"; declared and the value b is assigned
to it.
• Option 2 is legal, as a character variable named aChar is
declared and the value 0 is assigned
to it. In this case 0 is a character, not a numeric value.
• Option 3 is legal, as every character has got an integer
value associated with it called its
ASCII value. When 65 is assigned to aChar, 65 will be
implicitly converted to its corresponding
character. The assignment of an integer to a character
variable or vice versa is perfectly legal.
• Option 4 is illegal, as a character variable named aChar is
declared and then a string value cc
is assigned to it. No
ignment can be between two different types.
Your answer is correct.
The correct answer is:
char aChar = "cc";
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 2/32
,7/31/23, 5:26 PM Assessment 1: Attempt review
Question 3
Correct
Mark 2.00 out of 2.00
Given the following code fragment, what is the final value of y?
int x, y;
x = -1;
y = 0;
while(x <= 5)
{
y += 2;
x += 1;
}
a. 6
b. 12
c. 14
d. 18
Your answer is correct.
The correct answer is:
14
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 3/32
, 7/31/23, 5:26 PM Assessment 1: Attempt review
Question 4
Correct
Mark 2.00 out of 2.00
What is the output of the following code?
int value; value = 11.5;
cout << value << endl;
a. 11.5
b. 11 Correct option: 2
• Options 2 is correct as value is declared as a float value and
float value have decimal point
values.
• Option 1 is an integer value.
• Option 3 is a string value.
c. value
d. not defined
Your answer is correct.
The correct answer is:
11
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 4/32
UNISA 2023 INP1501-23-S2 Welcome Message Assessment 1
QUIZ
Started on Monday, 31 July 2023, 4:43 PM
State Finished
Completed on Monday, 31 July 2023, 5:26 PM
Time taken 42 mins 24 secs
Marks 80.00/90.00
Grade 88.89 out of 100.00
Question 1
Correct
Mark 2.00 out of 2.00
What is the value of x after the following statement?
float x;
x = 3..0 + 3 + ;
1. 1.75
2. 3.25
3. 3.75 Correct option: 3
There are two issues to take into consideration.
1. The type of the variable
a. x is declared as a float
b. 2 and 5 is integer values (not 2.0)
c. = 0.4
d. But as it is integer values the result will be 0
2. The order of the operations (p17 of the study guide). In
summary, first * and / and then +
and -. But if the operations are the same – from left to right
3..0 + 3 +
Step 1. 0.75 + 3 +
Step 2. 0.75 + 3 + 0
Step 3. 0.75 + 3
Step 4. 3.75
• In Option 1 ,2 and 4 the calculations are incorrect.
4. 5.75
Your answer is correct.
The correct answer is:
3.75
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 1/32
,7/31/23, 5:26 PM Assessment 1: Attempt review
Question 2
Correct
Mark 2.00 out of 2.00
Which of the following statements is NOT legal?
a. char aChar = 'c';
b. char aChar = '0';
c. char aChar = 65;
d. char Correct option: 4
aChar = • Option 1 is legal, as a character variable named aChar is
"cc"; declared and the value b is assigned
to it.
• Option 2 is legal, as a character variable named aChar is
declared and the value 0 is assigned
to it. In this case 0 is a character, not a numeric value.
• Option 3 is legal, as every character has got an integer
value associated with it called its
ASCII value. When 65 is assigned to aChar, 65 will be
implicitly converted to its corresponding
character. The assignment of an integer to a character
variable or vice versa is perfectly legal.
• Option 4 is illegal, as a character variable named aChar is
declared and then a string value cc
is assigned to it. No
ignment can be between two different types.
Your answer is correct.
The correct answer is:
char aChar = "cc";
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 2/32
,7/31/23, 5:26 PM Assessment 1: Attempt review
Question 3
Correct
Mark 2.00 out of 2.00
Given the following code fragment, what is the final value of y?
int x, y;
x = -1;
y = 0;
while(x <= 5)
{
y += 2;
x += 1;
}
a. 6
b. 12
c. 14
d. 18
Your answer is correct.
The correct answer is:
14
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 3/32
, 7/31/23, 5:26 PM Assessment 1: Attempt review
Question 4
Correct
Mark 2.00 out of 2.00
What is the output of the following code?
int value; value = 11.5;
cout << value << endl;
a. 11.5
b. 11 Correct option: 2
• Options 2 is correct as value is declared as a float value and
float value have decimal point
values.
• Option 1 is an integer value.
• Option 3 is a string value.
c. value
d. not defined
Your answer is correct.
The correct answer is:
11
https://mymodules.dtls.unisa.ac.za/mod/quiz/review.php?attempt=11678042&cmid=673152 4/32