Question 1
What operation does the following pseudocode perform?
Declare an array "word" of string data type
Declare a variable l
Take a string as input in the word
for l = 0 to 0
print word[l]
End for
Algorithm End
It prints the last character of the string
It prints characters in increasing order
It prints the first character of the string
It reverses the string
Question 2
Predict the output of the following pseudocode for x = 4, y = 9.
Integer solve(Integer x, Integer y)
if(y > 0)
if(x > 0)
return x + y + solve(0, y + 1) + solve(0, y + 2) + solve(x + 3, 0)
End if
End if
return x + y
End function solve()
20
15
41
30
Question 3
Predict the output of the following pseudocode for a = 11, b = 12.
Integer solve(Integer a, Integer b )
if(a < 3 && b < 4)
return solve(a + 1, b + 1)
Else
Return a + b
End if
End function solve()
13
12
22
23
Question 4
Predict the output of the following pseudocode
Integer x, y, z
Set x = 10, y = 16, z = 3
if(x > y)
x = y
Else
y = x
End if
if(z > y)
z = y
Else
y = z
End if
Print x + y + z
13
12
16
20
Question 5
Calculate the output of the following pseudocode.
Integer w, x, y, z
Set w = 1, x = 1
for (each y from 11 to 20 )
for (each z from -3 to 0 )
w = w + 5
if(w > y)
Continue
End if
w = 1
if(w > z)
Jump out of the loop
End if
End for
End for
Print w + x
8
22
3
2
Question 6
Calculate the output of the following pseudocode for input p = 3, q = 8, r = 1.
Integer p, q, r, sum
Read p, q, r
Set sum = p + q + r
if ((p NOT EQUALS 0) and (sum EQUALS 11) and (q EQUALS 4) and (r NOT EQUALS 0))
Print " Success"
Otherwise
Print "Fail"
End ifSuccess
Fail
Error
None of the above
Question 7
Calculate the output of the following pseudocode.
Integer a, b, c, d
Set a = 1, b = 1
for (each c from 1 to 2 )
for (each d from -2 to 0 )
a = a + 2
if(a > c)
Continue
End if
a = 1
if(a > d)
Jump out of the loop
End if
End for
End for
Print a + b
8
22
30
14
Question 8
Integer x, y, z
Set x = 8, y = 6, z = 4
if(x > y)
x = y
Else
y = x
End if
if(z > y)
z = y
Else
y = z
End if
Print x + y + z
13
17
14
23
Question 9
Print the output of the following pseudocode for x = 9, y = 7.
Integer funn(Integer x, Integer y)
Integer z
Set z = 2
y = y mod z
x = x mod z
return x + y
End function funn()
2
3
17
5
Question 10
Predict the output of the following pseudocode.
Integer x, y, z
Set x = -2, y = 3, z = 1
if(x + (2 & 2) && y + (3 & 3) && z + (2 ^ 2))
x = x - 2
y = x
Else
x = z
y = y ^ 2
End if
Print x+ y+ z
2
11
3
0
There are 20 questions to complete.