Pseudo code MCQ questions
1. What will be printed by the following pseudocode?
BEGIN
X ← 8
IF X > 5 THEN
PRINT "Hello"
ELSE
PRINT "Bye"
ENDIF
END
A) Hello
B) Bye
C) Nothing
D) Error
Answer: A
2.What will be the output of the following pseudocode?
BEGIN
COUNT ← 1
WHILE COUNT <= 3 DO
PRINT COUNT
COUNT ← COUNT + 1
ENDWHILE
END
A) 1 2 3
B) 1 2 3 4
C) 0 1 2
D) Infinite loop
Answer: A
3. What will be the output of the following pseudocode?
BEGIN
X ← 10
Y ← 20
IF (X > 5 || Y < 15) THEN
PRINT "Condition Met"
ELSE
PRINT "Condition Not Met"
ENDIF
END
A) Condition Met
B) Condition Not Met
C) Error
D) Nothing
Answer: A
4. What is the output of the following pseudocode?
less
CopyEdit
BEGIN
A ← FALSE
B ← FALSE
C ← A || B
PRINT C
END
A) TRUE
B) FALSE
C) NULL
D) ERROR
Answer: B
5. What will be the output of the following pseudocode?
Integer x, y, Z, a
Set x=2,y=1,z=5
a = (x AND y) OR (z + 1)
Print a
A. 5
B. 3
C. 2
D. 1
Answer : Option D
Explanation:
Here x = 2, y = 1, z = 5
a = (2 && 1) || (5 + 1)
= (1) || (6)
=1
So it will print 1
Answer is option D
6. What will be the output of the following pseudocode for p = 3 and
q = 4?
int fun1(int p, int q)
if(q EQUALS 0)
return 0
if(q mod 2 EQUALS 0)
return fun1(p + p, q/2) .
return fun1(p + p, q/2) + p
End function fun1()
A. None of the options
B. 7
C. 12
D. 8
Answer : Option C
7. What is the output of the following pseudocode?
BEGIN
COUNT ← 5
WHILE COUNT > 0 DO
PRINT COUNT
COUNT ← COUNT - 1
ENDWHILE
END
A) 5 4 3 2 1
B) 1 2 3 4 5
C) Infinite loop
D) 5 3 1
Answer: A
8. What will be printed by the following pseudocode?
pgsql
CopyEdit
BEGIN
X ← 0
WHILE X < 3 DO
PRINT "Looping"
ENDWHILE
END
A) Looping Looping Looping
B) Infinite loop
C) No output
D) Error
Answer: B
9. What is the output of the following pseudocode?
pgsql
CopyEdit
BEGIN
SUM ← 0
FOR I FROM 1 TO 4 DO
SUM ← SUM + I
ENDFOR
PRINT SUM
END
A) 10
B) 6
C) 4
D) 15
Answer: A (1+2+3+4 = 10)
10. How many times does this loop run?
BEGIN
I ← 1
WHILE I <= 5 DO
PRINT I
I ← I + 2
ENDWHILE
END
A) 2
B) 3
C) 4
D) 5
Answer: B