Question 31
MediumWhat will be the output of the following pseudocode?
Integer d = 3
switch (d)
case 1: Print "Mon"
case 2: Print "Tue"
case 3: Print "Wed"
case 4: Print "Thu"
default: Print "End"
end switch
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 d = 3
switch (d)
case 1: Print "Mon"
case 2: Print "Tue"
case 3: Print "Wed"
case 4: Print "Thu"
default: Print "End"
end switch
End
Wed
Wed Thu
Wed Thu End
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 5, b = 5
if (a == b)
if (a > 3)
Print "X"
else
Print "Y"
end if
else
Print "Z"
end if
X
Z
Y
XY
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer n = -4
Integer r = (n < 0) ? -n : n
Print r
-4
8
4
0
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer p = 0, q = 0
if (p == 0 OR q / p > 1) // OR stops as soon as the result is known
Print "Safe"
else
Print "Error"
end if
Nothing
Safe
Division by zero
Error
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 15, b = 25, c = 20
if (a > b and a > c)
Print a
else if (b > c)
Print b
else
Print c
end if
25
60
20
15
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer y = 1900
if ((y mod 4 == 0 and y mod 100 != 0) or y mod 400 == 0)
Print "leap"
else
Print "common"
end if
leap
1900
error
common
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer m = 72
if (m >= 90)
Print "A"
else if (m >= 75)
Print "B"
else if (m >= 60)
Print "C"
else
Print "F"
end if
C
A
F
B
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 0, y = 5
if (x != 0 and y / x > 1)
Print "big"
else
Print "safe"
end if
safe
Division by zero error
big
5
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer a = 3, b = 3, c = 4
if (a == b and b == c)
Print "equilateral"
else if (a == b or b == c or a == c)
Print "isosceles"
else
Print "scalene"
end if
scalene
isosceles
invalid
equilateral
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer n = 7, r = 0
if (n mod 2 == 1)
r = r + 1
end if
if (n > 5)
r = r + 10
else if (n > 3)
r = r + 100
end if
Print r
11
101
111
10
Sign up free to see the answer and a step-by-step explanation.