NEW
Font size
S
M
L
XL
Worksheets9618 functions,procedures,string functions-recap
Total questions: 20
Worksheet time: 10mins
Name
Class
Date
1.
Consider the pseudocode:
PROCEDURE Calculate(x, y)
CALL Calculate(5, 10)
CALL Calculate(3, 4).
How many times is the procedure 'Calculate' called?
a)
1
b)
2
c)
3
d)
4
2.
Which parameter passing method allows modification of the original variable?
a)
By Value (BYVAL)
b)
By Reference (BYREF)
c)
By Copy
d)
By Constant
3.
Evaluate the expression: MID('Hello World', 7, 5). What is the result?
a)
'World'
b)
'Hello'
c)
'Worl'
d)
'ello'
4.
What is the key difference between procedures and functions?
a)
Functions can only have one parameter
b)
Procedures return values, functions do not
c)
Functions return values, procedures do not
d)
Procedures are faster than functions
5.
In the expression RIGHT('ABCDEFGH', 3), what is returned?
a)
'ABC'
b)
'FGH'
c)
'CDE'
d)
'EFG'
6.
What is the result of the expression INT(27.5415)?
a)
28
b)
27.5
c)
27
d)
27.54
7.
What would the expression LENGTH(UCASE('Hi') & LCASE('BYE')) return?
a)
5
b)
6
c)
7
d)
8
8.
Which string function would you use to extract a substring from a given position?
a)
LEFT
b)
RIGHT
c)
MID
d)
LENGTH
9.
In the pseudocode FUNCTION Max(a, b) RETURNS INTEGER, what is the purpose of the RETURNS keyword?
a)
To define the function's parameters
b)
To specify the data type of the function's return value
c)
To call the function
d)
To declare a variable
10.
What would be the output of the expression RIGHT(LEFT('COMPUTER', 4), 2)?
a)
'CO'
b)
'MP'
c)
'PU'
d)
'ER'
11.
Consider the pseudocode:
PROCEDURE UpdateNumber(BYVAL x)
x = x + 1.
What happens to the original variable after the procedure call?
a)
It is incremented by 1
b)
It remains unchanged
c)
It is decremented by 1
d)
It is set to zero
12.
How many procedure calls are executed in this code snippet:
PROCEDURE Main()
CALL Display()
x ← Calculate(5)
CALL Update()
result ← GetValue()
ENDPROCEDURE
a)
2
b)
3
c)
4
d)
1
13.
What is returned by: UCASE(MID('Programming', 3, 4)) & LCASE(RIGHT('HELLO', 2))?
a)
OGRAlo
b)
PROGlo
c)
OGRALo
d)
PROGLo
14.
Which parameter passing method should be used when you need to modify the original variable in a procedure?
a)
BYVAL
b)
BYREF
c)
RETURN
d)
CALL
15.
In the function call: Process(LENGTH('Hi') + 2, RIGHT('World', 3)), what are the parameter values?
a)
4, 'rld'
b)
2, 'World'
c)
5, 'ld'
d)
Hi2, 'rld'
16.
Which is NOT a valid function declaration?
a)
FUNCTION Calculate() RETURNS INTEGER
b)
FUNCTION Process(x: REAL) RETURNS BOOLEAN
c)
FUNCTION Update(BYREF num: INTEGER) RETURNS INTEGER
d)
FUNCTION GetValue(CALL x: INTEGER) RETURNS INTEGER
17.
How many string function calls are in: result ← LENGTH(LEFT(text,2)) + LENGTH(RIGHT(text,3))?
a)
2
b)
3
c)
4
d)
5
18.
Which statement about functions is FALSE?
a)
Functions must return a value
b)
Functions can use BYREF parameters
c)
Functions can be used in expressions
d)
Functions don't need the CALL keyword
19.
In a procedure with parameters (x: INTEGER, text: STRING), what happens if you pass (3.5, '12')?
a)
x gets 3, text gets '12'
b)
Type mismatch error for x
c)
Both parameters cause errors
d)
x gets 4, text gets '12'
20.
What will be the final value of x after:
PROCEDURE Update(BYREF x:INTEGER)
x ← x + 1
ENDPROCEDURE
x ← 5
CALL Update(x)?
a)
5
b)
6
c)
Undefined
d)
Error
Reset
