Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 244 pages
Exam (elaborations)

COS1511 E EXAM PACK 2026

Document preview thumbnail
Preview 3 out of 244 pages

Latest exam pack questions and answers and summarized notes for exam preparation. for assistance. All the best on your exams!!

Content preview

COS1511

EXAM PACK

, Oct/Nov 2021




75 Marks




This examination question paper consists of 9 pages.




INSTRUCTIONS:

Use word Document to answer the questions
Convert to PDF before submitting
Marks are awarded for part of an answer, so do whatever you are able to in each question.
This exam is IRIS invigilated. Please make sure you use IRIS.




ALL THE BEST!




[TURN OVER]

, 2 COS1511
Oct/Nov 2021




QUESTION 1 6 MARKS

1.1 Consider the C++ code segment below. What value will newvalhave after this code has been
executed? (2)

int var1 = 4;
int var2 = 10;
int newval = 0;
if (var1 * 2 >= var2)
newval = 5 + 2 * var2;
else if (var1 < var2)
newval = var2 - var1 * 2;
else
newval = var1;

1.2 Suppose the input value for a is 5. What is the value of a after the following C++ code has
been executed? (2)

int a;
cin >> a;
switch (a)
{
case 1: a += 3;
case 3: a = a * 3; break;
case 5: a = ++a + 10;
case 6: a /= 2;
default: a = a + 1;
}

1.3 Consider the following C++ code segment: (2)

int findValue(int numberP)
{
int count = 0;
int value = 20;
while (count < numberP)
{
value += count;
count ++;
}
return value;
}

What will be the output of the following statement executed in the main function?

cout << findValue(3);




[TURN OVER]

Connected book
 image
Publisher: 2018 ISBN: 9781788834162 Edition: Unknown

Document information

Uploaded on
December 8, 2021
File latest updated on
October 21, 2022
Number of pages
244
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$4.80

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
EduPal
4.2
(14370)
Sold
154038
Followers
36024
Items
5142
Last sold
1 hour ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions