Question 1
EasyWhat will be the output of the following pseudocode?
Integer a = 17, b = 5
Print a / b // integer division
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Pseudocode and Output Prediction
What will be the output of the following pseudocode?
Integer a = 17, b = 5
Print a / b // integer division
3.4
3
4
2
Answer: B
Integer division discards the fractional part: 17 / 5 = 3.
What will be the output of the following pseudocode?
Integer a = 17, b = 5
Print a mod b
2
0
3
5
Answer: A
17 = 3 × 5 + 2, so the remainder is 2.
What will be the output of the following pseudocode?
Integer x = 2 + 3 * 4
Print x
14
24
20
9
Answer: A
Multiplication comes before addition: 2 + 12 = 14.
What will be the output of the following pseudocode?
Integer x = (2 + 3) * 4
Print x
14
9
24
20
Answer: D
Brackets are evaluated first: 5 × 4 = 20.
What will be the output of the following pseudocode?
Integer x = 10
x = x + 5
x = x * 2
Print x
15
20
25
30
Answer: D
Statements run in order: x = 10 + 5 = 15, then x = 15 × 2 = 30.
What will be the output of the following pseudocode?
Integer a = 5, b = 8
Print a > b
5
0
8
1
Answer: B
5 > 8 is false; as in C, false is printed as 0.
What will be the output of the following pseudocode?
Integer x = 7
x = x mod 4 + x / 4 // integer division
Print x
3
4
2
1
Answer: B
7 mod 4 = 3 and 7 / 4 = 1, so x = 4.
What will be the output of the following pseudocode?
Print 10 + 3 * 2
16
26
23
15
Answer: A
Multiplication comes before addition: 3 × 2 = 6, then 10 + 6 = 16.
What will be printed by the following pseudocode?
Print (10 + 3) * 2
23
26
15
16
Answer: B
Brackets first: 13 × 2 = 26.
What will be printed by the following pseudocode?
Print 17 mod 4
4
3
4.25
1
Answer: D
mod gives the remainder: 17 = 4 × 4 + 1, so 17 mod 4 = 1.