Question 41
MediumWhat is the output of this pseudocode?
Integer t = 35
if (t > 30)
if (t > 40)
Print "very hot"
else
Print "hot"
end if
else
Print "pleasant"
end if
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 is the output of this pseudocode?
Integer t = 35
if (t > 30)
if (t > 40)
Print "very hot"
else
Print "hot"
end if
else
Print "pleasant"
end if
hot
very hot
pleasant
hot pleasant
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 = 10
if (a > b)
a = a - b
else
b = b - a
end if
if (a == b)
Print "same", a
else
Print a, b
end if
-5 10
5 5
5 10
same 5
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer x = 8, c = 0
if (x > 5) c = c + 1
if (x > 6) c = c + 1
if (x > 9) c = c + 1
if (x mod 4 == 0) c = c + 5
Print c
3
7
2
8
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer d = 3
switch (d)
case 1: Print "Mon"
case 2: Print "Tue"
case 3: Print "Wed"
case 4: Print "Thu"
break
default: Print "Other"
end switch
Other
Wed Thu Other
Wed
Wed Thu
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 10, b = 20, c = 30
Integer m = a
if (b > m) m = b
if (c > m) m = c
if (m - a > 15)
Print m - a
else
Print m + a
end if
40
10
30
20
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer p = 1, q = 0
if (not (p == 1 and q == 1))
Print "A"
end if
if (not p == 1 or q == 0)
Print "B"
end if
A
Nothing is printed
B
A B
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer amt = 2500, disc
if (amt > 5000)
disc = amt * 20 / 100
else if (amt > 2000)
disc = amt * 10 / 100
else
disc = 0
end if
Print amt - disc
250
2250
2000
2500
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer n = 0
if (n)
Print "true"
else
Print "false"
end if
if (n == 0 or n / 0 == 1)
Print "ok"
end if
false
Division by zero error
true ok
false ok
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 4, b = 7
if (a mod 2 == 0)
if (b mod 2 == 0)
Print "both even"
else
Print "only a even"
end if
else if (b mod 2 == 0)
Print "only b even"
else
Print "both odd"
end if
only a even
only b even
both odd
both even
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer h = 14
if (h < 12)
Print "morning"
else if (h < 17)
Print "afternoon"
else if (h < 20)
Print "evening"
else
Print "night"
end if
morning
night
evening
afternoon
Sign up free to see the answer and a step-by-step explanation.