1. What will be the output of the following pseudocode for a = 9, b = 7?
Integer funn(Integer a, Integer b)
Integer c
Set c = 2
b = b mod c
a = a mod c
return a + b
End function funn()
-5
17
Answer: 2
2. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 8, b = 6,c = 4
If(a > b)
a=b
Else
b=a
End If
If(c> b)
c=b
Else
b=c
End If
Print a + b + c
13
14
17
23
Answer: 14
3. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 1, c = 7
a=a+b
if(a + b)
if(b + (c ^ a))
a=2
b=a
End if
End if
Print a + b + c
11
22
12
Answer: 11
4. What will be the output of the following pseudocode?
Integer p, q, r, s
Set p=1, q = 1
for (each r from 0 to 2 )
for (each s from -4 to -2 )
p = p + 2if(p > r)
Continue
End if
p = 1if(p > s)
Jump out of the loop
End if
End for
End for
Print p + q
35
13
24
20
Answer: 20
5. What will be the output of the following pseudocode for input a = 30, b = 60, and C = 90?
Integer a, b, c, sum
Read a, b, c
Set sum = a + b + c
if ((sum EQUALS 180) and (a NOT EQUALS 0) and (b NOT EQUALS 0) and (c NOT EQUALS 0))
Print " Success"
Otherwise
Print "Fail"
End if
Success
Fail
Error
None of the above
Answer: Success
6. What will be the output of the following pseudocode for a =1, b =2?
Integer funn(Integer a, Integer b )
if(a<3 && b<4)
return funn( a +1, b + 1)
Else
Return a + b
End if
End function funn()
7
-7
19
Answer: 7
7. What will be the output of the following pseudocode for a = 2, b = 6?
Integer funn(Integer a, Integer b
If(a > 0)
If(b > 0)
Return a + b + funn(a + 1, 0) + funn(a + 2, 0) + funn(a + 3, 0)
End If
End If
Return a + b
End Function funn()
21
20
17
37
Answer: 20
8. What will be the output of the following pseudocode for a = 4, b = 6?
Integer funn(Integer a, Integer b)
If(a > 2)
If(b > 2)
Return a + b + funn(a + 1, b – 5)
End If
End If
Return a – b
End function funn()
12
14
17
22
Answer: 14
9. What will be the output of the following pseudo-code:
Integer p, q, r
Set p= 3, q =1, r = 2
If(p+ (2&2&2) && q + (3&3&3) && r + (2^2^2))
p=p–2
q=p
Else
p=r
q = q2
End If
Print p+ q+ r
8
-8
16
Answer: 4
10. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 0, q = 4, r = 3
If(p || r)
If(p && r)
p = p &r
End If
p = pr
End If
Print p + q + r
10
20
12
Answer: 10
11. What will be the output of the following pseudocode for a = 4 and b = 9?
Integer funn(Integer a, Integer b)
If(a < b)
Return 1 + funn(a, b – 2)
End If
If(a^b > a&b)
Return a ^ b
Else
Return a & b
End If
Return 1
End function funn()
10
-8
14
24
Answer: 10
12. What will be the output of the following pseudocode for a = 4, b = 6?
Integer funn(Integer a, Integer b)
If(a > 1)
Return a * funn (b – 6, a – 4)
Else
Return 1
End If
Return a + b
End function funn()
17
Answer: 4
13. What will be the output of the following pseudocode?
Integer p, q, r
Set q = 30, p = 10, r = 20
If (r > (r + p))
q=1
Else
p=p–2
r=r–2
End If
If (r > (q + p) || 1)
q = (0 ^ 5)
Else
p=p+2
r=p+2
End If
Print p + q + r
31
20
30
40
Answer: 31
14. What will be the output of the following pseudocode?
Integer count
For (each count from 0 to 9)
Print "#"
If (count > 6)
CONTINUE
Print count
End For
0#1#2#3#4#5#6#7#8#9#10
0#1#2#3#4#5#6###
‘#0#1#2#3#4#5##7#8#9#10
‘#0#1#2#3#4#5#
Answer: #0#1#2#3#4#5#
15. What will be the output of the following pseudo-code:
Integer m
Set m = 0
Integer p[5] = {1, 1, 0, 1, 7}
If (p[0] && P[4])
m = p[1]
End If
If (p[2] && p[3])
m = p[2]
End If
Print m
-5
18
Answer: 1