**Pseudo code** is a term which is often used in programming and algorithm based fields. It is a methodology that allows the programmer to represent the implementation of an algorithm. It is not executable by compiler but it gives clear instruction how to implement the executable algorithm.

Pseudo Code Questions test candidates knowledge to understand and comprehend the algorithm.Let’s see some of the frequently asked pseudo code questions to get better understanding.

## Pseudo Code Questions And Answers

#### 1. What will be output of the given pseudo code questions?

Integer a, b, c Set b = 4, c = 5 for(each a from 2 to 4) print c b = b - 1 c = c + b end for

- 5 8 10
- 1 3 6
- 8 9 10
- 3 6 9

**Answer**: Option 1) **5 8 10**

**Explanation**:

Firstly, b and c are assigned values 4 and 5 respectively.

Now run a loop from 2 to 4, in each iteration b is decremented by 1, and c is incremented by b.

First iteration print c i.e. 5 value of b is decremented by 1 i.e. b = 3, c is incremented by b i.e. c = 5 + 3 =8

Second iteration print c i.e. 8 value of b is decremented by 1 i.e. b = 2, c is incremented by b i.e. c = 8+2= 10

Third iteration print c i.e. 10 value of b is decremented by 1 i.e. b = 1, c is incremented by b i.e. c = 10+1 =11

#### 2. Provide the Output of following Pseudo code Questions

Integer x, y Set x = 15, y = 12 y = x – 1 do{ Print x x = y + (x – 2) } while(x < 40) end do while

- 14 26
- 15 27 39
- 27 39
- 15

**Answer**: Option 2) ** 15 27 39**

**Explanation**:

Firstly, x and y are assigned values 15 and 12 respectively.

Then y the value of x – 1. i.e 14.

print x i.e 15

do while loop runs till x is less than 40 , x= y + x – 2 and print x

The order in which value of x changes are: 15 then 27(14 + 15 – 2) then 39(14 + 27 – 2), then 51(14 + 39 – 2) and the do while loop terminates.

#### 3. Predict the output of the following pseudo code questions

Integer p, q, r, s Set p = 4, q = 2, r = 1 s = (p AND q) OR (r + 1) Print s

- 1
- 2
- 3
- 5

**Answer**: Option 2) ** **2

**Explanation**:

At the start, value of p = 4, q = 2, r = 1

Then s = (p & q) | (r + 1)

s = 0 | 2

s = 2

#### 4. Find the output of the following pseudo code questions if x = 3 and y = 5:

Integer solve(int x, int y) if(x < 5) solve(x + 2, y) end if print y End function solve()

- 5
- 3
- 6
- 4

**Answer**: Option 1) ** **5

**Explanation**:

The value of y remains same as 5, no matter how many times recursion is called

#### 5. What will be output of following Pseudo Code Questions assuming p=4 and q=2:

Integer solve (Integer p, Integer q) Integer value while(q) value = p MOD q p = q q = value End while return p End function solve()

- 1
- 2
- 3
- 5

**Answer**: Option 2) ** **2

**Explanation**:

do while loop runs till q is not zero

In each iteration, the value of p, q changes in the order:4, 2 -> 2, 0, and the loop terminates

#### 6. What will be the output of the following pseudo code questions?

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

- 6
- 11
- 22
- 12

**Answer**: Option 2) ** **11

**Explanation**:

Initially a=1, b=1,c=7

Then a= 1+1 = 2

Since a+b=3 , it will enter if block

Since (b + (c ^ a))!=0, it will enter if block again

at last a=2,b=2, c=7, thus a+b+c=11

#### 7. What will be the output of the following pseudocode?

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
- 4
- -8
- 16

**Answer**: Option 2) ** **4

**Explanation**:

Initially p=3, q=1,r=2

*p+ (2&2&2) && q + (3&3&3) && r + (2^2^2)* will be 5 !=0, thus will enter if block

p=3-2=1 and q=1

thus p+q+r=4

#### 8. 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

- 7
- 10
- 20
- 12

**Answer**: Option 1) ** **7

**Explanation**:

Initially p = 0, q = 4, r = 3

p || r= 4 !=0, thus will go into if block

p&&r=0, thus it will not go into this if block

thus now p=pr will be executed thus p=0

p+q+r=7

## Conclusion

In this article we discussed Frequently Asked Pseudo Code Questions With Answers. Checkout Other commonly asked questions here

Got a question or just want to chat? Comment below or drop by our forums, where a bunch of the friendliest people you’ll ever run into will be happy to help you out!