Home News Contact About

Pseudo Code MCQs (previously asked)


1) What will be the value of s if n=127?
Read n
i=0,s=0
Function Sample(int n)
while(n>0)
r=n%l0
p=8^i
s=s+p*r
i++
n=n/10
End While
Return s;
End Function

a) 27
b) 187
c) 87
d) 120

Ans: Option C

2)What will be the output of the following pseudocode?
Integer n
for (n = 3; n != 0; n--)
Print n
n = n-1
end for

a) 3 1
b) 3 2 1
c) 3
d) Infinite Loop

Ans: Option C

3) What will be the output of the following pseudocode?
For input a = 8 & b = 9.
Function(input a, input b)
If(a < b)
return function(b, a)
elseif(b != 0)
return (a + function(a,b-1))
else
return

a) 56
b) 78
c) 72
d) 68

Ans: Option C

4) What will be the value of even_counter if number = 2630?
Read number
Function divisible(number)
even_counter = 0, num_remainder = number;
while (num_remainder)
digit = num_remainder % 10;
if digit != 0 AND number % digit == 0
even_counter= even_counter+1
End If
num_remainder= num_remainder / 10;
End While
return even_counter;

a) 3
b) 4
c) 2
d) 1

Ans: Option D

5) What will be the value of t if a =56 ,b = 876?
Read a,b
Function mul(a, b)
t = 0
while (b != 0)
t = t + a
b=b-1
End While
return t;
End Function

a) 490563
b) 49056
c) 490561
d) None of the mentioned

Ans: Option B

6) Code to sort given array in ascending order:
Read size
Read a[1],a[2],a[size]
i=0
While(i j=i+1
While(j If a[i] < a[j] then
t= a[i];
a[i] = a[j];
a[j] = t;
End If
j=j+1
End While
i=i+1
End While
i=0
While (i print a[i]
i=i+1
End While
Find out the wrong statement in the above pseudocode

a) Line 4
b) Line 6
c) Line 7
d) No Error

Ans: Option C

7) What is the time complexity of searching for an element in a circular linked list?

a) O(n)
b) O(nlogn)
c) O(1)
d) None of the mentioned

Ans: Option A

8) In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

a) log 2 n
b) n?2
c) log 2 n 1
d) n

Ans: Option D