Search Header Logo
Week 3 - Functions (DCS1101)

Week 3 - Functions (DCS1101)

Assessment

Presentation

Computers

University

Practice Problem

Medium

Created by

Yasmin Basiran

Used 4+ times

FREE Resource

22 Slides • 12 Questions

1

media

2

media

3

Poll

If you had to check “Pass/Fail” for 10 students, would you rather copy the code 10 times or reuse something?

Copy code 10 times

Reuse something

4

Open Ended

Why do humans divide work into roles?

5

media

6

media

7

media

8

media

9

media

10

media

11

media

12

media

13

media

14

media

15

Multiple Choice

What is the main purpose of a function?

1
The main purpose of a function is to display information.
2
A function is designed to create user interfaces.
3
The main purpose of a function is to perform a specific task or calculation.
4
A function is used to store data temporarily.

16

Multiple Choice

Where is a function prototype usually written?

1
In a comment section of the code.
2
At the end of a source file.
3
Within a function definition.
4
In a header file or at the beginning of a source file.

17

Multiple Choice

Passing data by value means:

1
The original data is modified directly.
2
A copy of the data is passed, not the original.
3
Data is passed as a reference to the original.
4
Only the metadata of the data is shared.

18

Multiple Choice

What does the return statement do?

1

The return statement exits a function and returns a value.

2
The return statement creates a new variable in the function.
3
The return statement deletes a function from memory.
4
The return statement pauses a function and saves its state.

19

media

20

media

21

media

22

media

23

media

24

media

25

Multiple Choice

What is the best way to explain a global variable?

1
A global variable is accessible throughout the entire program.
2
A global variable is limited to a single function.
3
A global variable can only be used in local scopes.
4
A global variable is automatically deleted after use.

26

Multiple Choice

Which error happens if return type mismatches?

1
Return type failure
2
Type error
3

Compilation error

4
Mismatch exception

27

media

28

media

29

Open Ended

Write a function that displays a welcome message "Hello!".

30

Open Ended

Write a function that returns true if a score above 50 is a pass.

31

Multiple Choice

What is the error of this code?

int total() {

return "10";

}

1
Type mismatch: returning a string instead of an integer.
2
Missing a return statement in the function.
3
Function name does not match its purpose.
4
Returning an integer instead of a string.

32

Open Ended

What is the error of this code?

int add(int a, int b) {

cout << a + b;

}

33

media

34

media
media

Show answer

Auto Play

Slide 1 / 34

SLIDE