100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

COS1511 EXAM PACK 2023

Rating
-
Sold
-
Pages
244
Grade
A+
Uploaded on
18-03-2022
Written in
2022/2023

Latest exam pack questions and answers, perfect for exam preparation

Institution
Course










Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Course

Document information

Uploaded on
March 18, 2022
File latest updated on
October 21, 2022
Number of pages
244
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

COS1511
EXAM PACK




+27 81 278 3372

, 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]

Get to know the seller

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.
VarsityC AAA School of Advertising
Follow You need to be logged in order to follow users or courses
Sold
28681
Member since
8 year
Number of followers
13258
Documents
3117
Last sold
6 days ago

4.1

2819 reviews

5
1490
4
581
3
392
2
117
1
239

Recently viewed by you

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

Frequently asked questions