Pseudocode Aptitude Questions with Solutions
40 Pseudocode questions with hints, worked solutions and time targets — 13 easy · 19 medium · 8 hard.
- Section: Programming MCQs
- Questions: 40
- By difficulty: 13 easy · 19 medium · 8 hard
- Cost: Free, unlimited on every plan
Trace the loop, print the output — the section Infosys and Wipro lean on.
Pseudocode: the essentials
Read the question's own conventions before tracing a single line.
Conventions to confirm
- Whether / is integer division, discarding the fraction, and MOD the remainder: 17 / 5 = 3 and 17 MOD 5 = 2.
- Whether arrays and strings are 0-indexed or 1-indexed. An n-element 0-indexed array ends at n − 1.
- 'For i = a to b' includes both ends; with step s it runs ⌊(b − a)/s⌋ + 1 times.
- While tests before the body and may run zero times; Repeat … Until tests after, runs at least once and stops when its condition becomes true.
- Break leaves the loop; Continue skips to the next pass. An Else If ladder runs only the first true branch.
- By value passes a copy; by reference passes the caller's variable itself.
Tracing
- Keep a trace table: one column per variable, one row per pass.
- Nested loops whose inner bound is the outer counter run n(n + 1)/2 times, not n².
- For recursion, write each pending expression on the way down and substitute on the way up. The base case counts as a call.
- Recognise stock routines: n MOD 10 with n / 10 peels digits; (a, b) → (b, a MOD b) is Euclid's GCD; a = a + b, b = a − b, a = a − b swaps; n MOD 2 with n / 2 counts binary 1s; two indices closing in test for a palindrome.
Questions
- Adding the even numbers Easy
What does the following pseudocode print? - Halving until one Medium
In the pseudocode below / is integer division: any fraction is discarded. What is printed? - Counting inner iterations Medium
How many times does the statement Set c = c + 1 execute? - Swapping without a third variable Easy
What does the pseudocode print? - Which branch fires Easy
What value of grade is printed? - Position of the largest element Easy
The array A is 1-indexed, so its elements are A[1] to A[6]. What is printed? - Walking an array backwards Easy
The array A is 0-indexed, so its elements are A[0] to A[4]. What is printed, in order? - Counting vowels Easy
Characters are numbered from 1, so s[1] is the first character. What does this print? - Recursion that steps by two Medium
What is printed? - How many calls are made Medium
Counting the first call from the main program, how many times is G invoked in total? - Call by value Medium
Parameters are passed by value. What is printed, in order? - One by reference, one by value Medium
The parameter marked ref is passed by reference; the other is passed by value. What does the program print? - What does this routine compute Medium
For positive integers a and b, what does Mystery(a, b) return? - Reversing a number Easy
/ is integer division and MOD is the remainder. What is printed? - Repeated multiplication Easy
What is printed? - A loop that steps by seven Easy
How many times does the body of the loop execute? - Leaving the loop early Medium
What is printed? - A post-tested loop Medium
A Repeat ... Until loop tests its condition after running the body. What is printed? - Sum over an upper triangle Medium
What is printed? - A product that keeps getting trimmed Easy
What is printed? - Multiples of three or four Hard
What is printed? - One pass of a bubble sort Medium
The array A is 0-indexed. What are the contents of A after the loop? - How many swaps does it perform Hard
The array A is 0-indexed. What is printed? - Comparisons in a linear search Medium
The array A is 1-indexed. How many times is the comparison A[i] == key evaluated? - Iterations of a binary search Hard
A is 1-indexed and holds A[i] = 10 × i, that is 10, 20, 30, ..., 150. / is integer division. What is printed? - Reversing a string in place Hard
Characters are numbered from 1 and / is integer division. What is printed? - Identify the test Medium
Characters are numbered from 1. What does Check(s) decide? - Adding the digits Easy
/ is integer division and MOD is the remainder. What is printed? - Skipping the diagonal Easy
What is printed? - Read, transform, print Medium
The program is run with the inputs a = 6 and b = 14, in that order. What is printed? - Rotating three variables Medium
What is printed? - Counting remainders on division by two Hard
/ is integer division. What is printed? - Rotating an array left Medium
The array A is 0-indexed. What are its contents at the end? - Which diagonal is being added Medium
The matrix M is 1-indexed in both dimensions. What is printed? - What is being returned Easy
The array A is 1-indexed and holds n elements. What does F(A, n, x) return? - A condition that is never met Hard
What is printed? - Two routines calling each other Hard
What is printed? - Continue and Break in one loop Medium
What is printed? - Tracking two extremes at once Medium
The array A is 0-indexed. What is printed? - Counting steps to one Hard
/ is integer division. How many times does the body of the loop run?
Placement tests that ask pseudocode
- Big Tech Screen — Theory Drill CodeKairo
- Infosys SE / DSE — Aptitude Infosys
- Accenture — Cognitive & Technical Accenture
- Capgemini — Technical & English Capgemini
- Tech Mahindra — Aptitude & Technical Tech Mahindra
- Amazon — SDE Online Assessment Amazon
- LTIMindtree — Online Assessment LTIMindtree
- Mphasis — AMCAT Assessment Mphasis
- Virtusa — Online Test & Coder Challenge Virtusa
- Morgan Stanley — Aptitude & Technical Morgan Stanley
- Zoho — Round 1 Zoho