Skip to document

CSC01A1 2022 ST1 SSA - past paper

past paper
Course

Computer Science (CSC1B)

103 Documents
Students shared 103 documents in this course
Academic year: 2024/2025
Uploaded by:
0followers
3Uploads
0upvotes

Comments

Please sign in or register to post comments.

Preview text

UNIVERSITY OF JOHANNESBURG

FACULTY OF SCIENCE

COMPUTER SCIENCE APK CAMPUS

CSC01A

INTRODUCTION TO ALGORITHMS (C++)

SEMESTER TEST 1 - SSA

2022 - 03 - 22

EXAMINER Dr JL du Toit

MODERATOR Mr S Sithungu

TIME 40 Minutes MARKS 40

Please read the following instructions carefully

1. Answer only in the provided answer books (do not fill in on the question paper)

2. Write your details on both the question and answer books

3. Place your question paper inside your answer book before handing in

4. Write clearly and legibly.

5. The use of electronic calculators is not permitted

6. This paper consists of 5 pages

STUDENT

SURNAME, INITIALS

Question 1 Answer in the provided answer book

a) Convert 00 11 1011 0101 01002 into Hexadecimal:

b) Convert C7 16 into Binary:

c) Convert 2 78 into Binary:

d) Convert 1 1012 into Decimal:

e) Convert 101 0112 into Octal:

[5]

[5]

refers to a question which is itself invalid.

Question 2 Answer in the provided answer book

a)

Which one of the following Windows command line instructions will clear

the current terminal of all content?

A

ls

B

clear

C

cls

D

pause

E

empty

b)

Which one of the following C++ data types can successfully store a value of

168?

A

int

B

string

C

char

D

bool

E

large

c)

The linker translates the program code into machine language

TRUE FALSE

d)

Which one of the following characters are used to start a multi-line

comment in C++?

A

*/

B

/*

C

//

D

;

E

REM

e)

Which one of the following characters represent a Boolean AND operation

in c++?

A

&&

B

$$

C

%%

D

||

E

++

cout << intNew << " "; //Output new term

intPrev = intNew;

}

cout << endl;

}

break;

case 'b':

case 'B':

{

cout << "Please type in some words" << endl;

string strWords = "";

(g).ignore(100,'\n'); //Ignore chars in buffer

getline(cin,strWords); //Get whole line

(h) strNew; //Reversed word

for(char c:strWords) //Iterate through each char

{

strNew = c+strNew;

}

cout << strNew << endl;

}

break;

case 'x':

case 'X':

blnContinue = (i);

break;

default:

cerr << "Invalid option. Please retry" << endl;

}

system("pause"); //Runs a Windows pause command

}(j)(blnContinue);

return 0;

}

Question 4: Program Design [10]

Write your answers in the answer book provided.

a)

Draw a circuit diagram to represent the following logical expression:

NOT((A AND B) OR (C XOR D))

(5)

b)

Using an appropriate UML notation model the following:

The Utopian national forest requires a fire-warning system for the Utopian National Park.

The park can take a limited number of visitors and each of the following factors influence

the warning level. The user of the system inputs each of the following factors:

  • Percentage of visitors in the park (15% weighted).
  • Percentage of cooking fires (55% weighted).
  • Percentage of dry wood in the park (30% weighted).

The following output should be produced depending on the weighted average:

  • [0-35): “Green: Minimal staff required”
  • [35-65): “Yellow: Staff must be on standby”
  • [65-100]: “Red: All hands on deck”

(5)

Question 5: Program Implementation [10]

Please write C++ code in the answer book provided which implements the design from

question 4b). You may assume that the different levels are available from the standard input

stream. You do not need to handle errors, except the out-of-range error already mentioned

in question 4b.

Was this document helpful?

CSC01A1 2022 ST1 SSA - past paper

Course: Computer Science (CSC1B)

103 Documents
Students shared 103 documents in this course
Was this document helpful?
1 - 5
UNIVERSITY OF JOHANNESBURG
FACULTY OF SCIENCE
COMPUTER SCIENCE
APK CAMPUS
CSC01A1
INTRODUCTION TO ALGORITHMS (C++)
SEMESTER TEST 1 - SSA
2022-03-22
EXAMINER
Dr JL du Toit
MODERATOR
Mr S Sithungu
TIME
40 Minutes
MARKS
Please read the following instructions carefully
1. Answer only in the provided answer books (do not fill in on the question paper)
2. Write your details on both the question and answer books
3. Place your question paper inside your answer book before handing in
4. Write clearly and legibly.
5. The use of electronic calculators is not permitted
6. This paper consists of 5 pages
STUDENT #
SURNAME, INITIALS