Tutorial Questions for CSC 102
num1 = 45 What will the output of this code?
num2 = 7
grade = ‘C’
num3 = num1 mode num2
PRINT num3 CASE grade OF
What is the output of the above pseudo code? ‘A’: PRINT “Excellent”
‘B’: PRINT “Very Good”
a) Num3
‘C’: PRINT “Well done”
b) 4
OTHERWISE: PRINT “Try Hard”
c) Error
ENDCASE
d) 3
a) Excellent
A = 23 b) Very Good
B = 12 c) Well done
C=2
d) Try Hard
D = (A + B)*C
PRINT D age = 18
IF(age > 18) THEN
a) 47 PRINT “Age is equal to 18”
b) 35 ELSE
c) 70 PRINT “Age is not equal to 18”
d) 140 ENDIF
What will be the output of this code? a) Age is equal to 18
b) Age is not equal to 18
A=9
c) Age is greater than 18
B=1
C=2 d) Age is greater than or equal to 18
D=3
E = A*C + B*D – A/D age = 98
PRINT E IF(age > 18) THEN
IF(age < 100) THEN
a) 17 PRINT “Age is greater than 18 and less
b) 18 than 100”
c) 21 ELSE
d) 19 PRINT “Age is greater than 100”
ENDIF
What will be the output of this code? ELSE
PRINT “Age is not equal to 18”
A=9
B=1 ENDIF
C=2 a) Error
D=3 b) Age is not equal to 18
E = A*(C + B)*(D-A)/D c) Age is greater than 100
PRINT E d) Age is greater than 18 and less than 100
a) Error
b) -3
c) 4
d) -54
How many times will the following loop run? Determine the output below
myVar = “A Word” SET a = 3
WHILE (i < = len(myVar)) b = a++
PRINT “Executed” c = ++a
ENDWHILE PRINT a, b, c
a) 6 a) 5, 5, 3
b) 5 b) 3, 5, 5
c) 10 c) 5, 3, 5
d) 11 d) 5, 5, 5
What will be the output of this code below? A = (2 == 2) && (5 == 1) find A
7 + 16 / 2 ^ 4 * (3 - 1) a) True
a) 11 b) False
b) 9 c) I don’t know
c) 10
d) 8 B = (7 < = 7) || (1 > 4) find B
a) True
What will be the output of this code below? b) False
2 * 5 – (7 - 4) / 3 c) None of these
a) 10
b) 11 Determine the logical operator that is used
c) 12 below
d) 9 (2 == 2) && (4 == 4)
a) OR
Convert this mathematical expression into b) AND
pseudo code expression: a2 + b3 + c4 c) NOT
a) a * b + b ^ 3 + c d) None of these
b) a ^ 2 + b ^ 3 + c ^ 4
c) a ^ a + b ^ b + c ^ 2 Determine z below
d) None of these a=8
b=5
Convert this mathematical expression into z = SET mod a b
𝑏𝑠
pseudo code: Q = a + 𝑗−𝑑 a) – 7
a) a + (b * s) / (j - d) b) 7
c) 14
b) a+b*s/j–d
d) 8
c) a + bs / j – d
d) a + b * s / (j - d)
Determine the output below
READ x, y
Determine the output below c=x+y/2
x=4 PRINT c
y = x++ DATA 15, 25
PRINT x, y a) 20
a) 4, 4 b) 30
b) 4, 5 c) 40
c) 5, 4 d) 26
d) 4, 6
Determine the output below assuming x = 4 FOR (n = 1, n < = 4, n + 2)
Step1: INPUT x PRINT “loop”, n
Step 2: y = x ^ 3 ENDFOR
Step 3: PRINT y The above loops execute how many times
a) 8 a) 2
b) 16 b) 3
c) 64 c) 1
d) 14 d) 4
Determine the output below IF (mark > = 80) THEN
x=8 PRINT “Distinction”
b = “Computer Science” ENDIF
c = LEFT (b, x) If the mark is 70 what will be the output
PRINT c a) Distinction
a) Science b) Pass
b) Computer c) Credit
c) Computer Science d) Nothing
d) Science Computer
READ m1, m2, m3
Determine the output below sum = m1 + m2 + m3
n = “Problem Solving” avg = sum / 3
x = RIGHT (n, 7) IF (avg < 50) THEN
PRINT x PRINT “Fail”
a) Problem ELSE
b) Solving PRINT “Pass”
c) Problem Solving ENDIF
d) Solving Problem DATA 50, 40, 30
What will be the output?
Determine the output below a) Fail
m = “Hello World” b) Pass
k = MID (m, 7, 5) c) Program error
PRINT k d) None of these
a) Hello
b) World Determine the output below
c) World Hello SET a = 3
d) Hello World b = 51
c=2
Determine the output below c=a^c
a = STR (1479) b = b mod 4
b = LEN (“Come”) PRINT a + b + c
PRINT a, b a) 10
a) 1479, 4 b) 12
b) 1479, “4” c) 14
c) “1479”, 4 d) 15
d) “1479”, “4”
Determine the output below Determine the output below
SET word = “goose” x=6
a = LEN (word) WHILE (x <= 6)
PRINT a x = x +1
a) 2 ENDWHILE
b) 5 PRINT x
c) 7 a) 6
d) 10 b) 7
c) 8
Determine the output below d) 9
SET a = 15
b=7 Determine the output below
a = a mod (a - 3) x=0
b = b mod (b - 3) IF (x <> 0) THEN
PRINT a + b PRINT “True”
a) 6 ELSE
b) 7 PRINT “False”
c) 8 ENDIF
d) 9 a) True
b) False
Determine the output below c) I don’t know
SET b = 5
a=2 Determine the output below
c=2 i=1
IF (b > a AND a > c AND c > b) THEN IF (i++ AND i = = 1) THEN
b=a+1 PRINT “True”
ELSE ELSE
a=b+1 PRINT “False”
ENDIF ENDIF
PRINT a + b + c a) False
a) 10 b) True
b) 13 c) I don’t know
c) 16
d) 17
Determine the output below
x=5
WHILE (x++ < = 5)
PRINT x
ENDWHILE
a) 5
b) 6
c) 7
d) 9