Pseudo-code questions and answers
Trace loops, recursion and bitwise logic. Practise pseudo-code questions from the technical & programming section of placement tests, with a worked explanation after every answer. Practice is free and needs no sign-up.
Sample pseudo-code questions with worked answers
Question 1
What will be the output of the following pseudocode?
Integer a, b
Set a = 15, b = 4
a = a + b
b = a - b
a = a - b
Print a, b
- 15 4
- 19 15
- 4 15
- 4 4
Answer: C. 4 15
Explanation: a becomes 19, then b = 19 - 4 = 15, then a = 19 - 15 = 4. The values are swapped without a temporary variable.
Question 2
What will be the output of the following pseudocode? (Note: &, | and ^ are bitwise AND, OR and XOR.)
Integer a, b, c
Set a = 12, b = 7
c = a ^ b
a = c ^ a
Print a + c
- 23
- 18
- 19
- 11
Answer: B. 18
Explanation: c = 12 ^ 7 = 1100 ^ 0111 = 1011 = 11. Then a = 11 ^ 12 = 1011 ^ 1100 = 0111 = 7. a + c = 7 + 11 = 18.
Question 3
What will be the output of the following pseudocode?
Integer fun(Integer n)
if (n < 3)
return n
end if
return fun(n - 1) + fun(n - 3)
End function fun()
Print fun(7)
- 7
- 13
- 10
- 9
Answer: C. 10
Explanation: fun(0) = 0, fun(1) = 1, fun(2) = 2. Then fun(3) = 2 + 0 = 2, fun(4) = 2 + 1 = 3, fun(5) = 3 + 2 = 5, fun(6) = 5 + 2 = 7 and fun(7) = 7 + 3 = 10.
All 30 pseudo-code questions with answers
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode? (Note: &, | and ^ are…
- What will be the output of the following pseudocode? (Note: / denotes integer…
- What will be the output of the following pseudocode? (Note: &, | and ^ are…
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: << and >> are…
- What will be the output of the following pseudocode? (Note: / denotes integer…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: &, | and ^ are…
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode? (Note: array indices…
- What will be the output of the following pseudocode? (Note: / denotes integer…
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: / denotes integer…
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: array indices…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: &, ^ and >> are…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: array indices…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode? (Note: for-loop bounds…
Pseudo-code: common questions
What are pseudo-code questions?
Trace loops, recursion and bitwise logic. They appear in the technical & programming section of many placement tests.
Where can I practise pseudo-code questions with answers for free?
Right here on LogicWiz Exams. Every pseudo-code question has a worked explanation after you answer. Practice is free and needs no sign-up.
How should I practise pseudo-code?
Start with easy questions, then move to medium and hard. Read the explanation after each answer, and come back to the ones you missed.
Start practising
On this page you can start a fresh set of pseudo-code questions, choose easy, medium or hard, and time yourself if you want to. Or practise the whole subject: Technical & Programming practice.
More technical & programming topics
- C Programming: Output prediction, pointers and operators.
- Java: OOP, strings, collections and exceptions.
- Python: Data types, comprehensions and mutability.
- Data Structures: Arrays, stacks, queues, trees, graphs and hashing.
- Algorithms: Complexity, sorting, searching, recursion and DP.
- Object-Oriented Programming: Encapsulation, inheritance, polymorphism, abstraction.
- DBMS: Keys, normalisation, transactions and indexing.
- SQL: Joins, grouping, subqueries and query output.
- Operating Systems: Processes, scheduling, memory and deadlocks.
- Computer Networks: OSI/TCP-IP, protocols, addressing and ports.
- Software Engineering: SDLC, testing, agile and version control.
- Cloud & DevOps: Service models, containers, CI/CD and Linux.
- GenAI Basics: LLMs, tokens, prompting, embeddings and RAG.
Other subjects
- Quantitative Aptitude: Arithmetic, percentages, time and work, speed, probability and data interpretation: the numerical section of every fresher test.
- Logical Reasoning: Series, coding-decoding, arrangements, syllogisms and puzzles: the section that separates prepared candidates from the rest.
- Verbal Ability: Vocabulary, grammar, reading comprehension and sentence order: tested in nearly every IT services hiring exam.
- Python: Python quizzes by topic, from types and strings to classes and generators: output prediction and interview concepts.
- SQL: SQL quizzes by topic, from SELECT and joins to window functions: query output and concepts for analyst and developer roles.
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge · Test from a job description · LogicWiz Open: free team quiz · Free interview prep