Question 61
HardWhat is the output of this pseudocode?
Integer a = 7, b = 3, c = 9, t
if (a > b) t = a; a = b; b = t end if
if (b > c) t = b; b = c; c = t end if
if (a > b) t = a; a = b; b = t end if
Print a, b, c
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 a = 7, b = 3, c = 9, t
if (a > b) t = a; a = b; b = t end if
if (b > c) t = b; b = c; c = t end if
if (a > b) t = a; a = b; b = t end if
Print a, b, c
3 7 9
7 3 9
9 7 3
3 9 7
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer y = 2100
String r
if (y mod 400 == 0)
r = "leap"
else if (y mod 100 == 0)
r = "common"
else if (y mod 4 == 0)
r = "leap"
else
r = "common"
end if
Print r
leap
error
2100
common
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer marks = 74, bonus = 0
if (marks >= 70)
bonus = 5
end if
marks = marks + bonus
if (marks >= 90)
Print "A"
else if (marks >= 75)
Print "B"
else
Print "C"
end if
B
C
79
A
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 15
if (x mod 3 == 0 and x mod 5 == 0)
Print "FizzBuzz"
else if (x mod 3 == 0)
Print "Fizz"
else if (x mod 5 == 0)
Print "Buzz"
end if
if (x > 10 or x / 0 == 1)
Print "big"
end if
Fizz big
FizzBuzz
FizzBuzz big
Division by zero error
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer a = 4, b = 9, c = 4
if (a == b and b == c)
Print 3
else if (a == b or b == c or a == c)
Print 2
else
Print 0
end if
0
3
2
1
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer n = 0, i
for (each i from 1 to 20)
if (i mod 2 == 0)
if (i mod 3 == 0)
n = n + 10
else
n = n + 1
end if
else if (i mod 5 == 0)
n = n + 100
end if
end for
Print n
237
337
231
137
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer h = 23, m = 50, add = 25
m = m + add
if (m >= 60)
h = h + m / 60
m = m mod 60
end if
if (h >= 24)
h = h - 24
end if
Print h, m
23 75
1 15
24 15
0 15
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer a = 5, b = 10
Boolean p = (a > 3) and not (b < 5)
Boolean q = not (a > 3 or b > 20)
if (p and not q)
Print "first"
else if (p or q)
Print "second"
else
Print "third"
end if
third
first
first second
second
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer w = 72, h = 180
Integer bmi10 = w * 100000 / (h * h)
if (bmi10 < 185)
Print "under"
else if (bmi10 < 250)
Print "normal"
else
Print "over"
end if
under
over
normal
222
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer x = -7
Integer s
if (x > 0)
s = 1
else if (x < 0)
s = -1
else
s = 0
end if
Integer a = x * s
Print s, a
0 0
1 -7
-1 7
-1 -7
Sign up free to see the answer and a step-by-step explanation.