Question 51
MediumWhat does the following pseudocode print?
Integer x = 5, y = 10, z
z = (x > y) ? x : y
z = (z mod 2 == 0) ? z / 2 : z * 3
Print z
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 does the following pseudocode print?
Integer x = 5, y = 10, z
z = (x > y) ? x : y
z = (z mod 2 == 0) ? z / 2 : z * 3
Print z
15
5
10
30
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 2, b = 3, c = 5
if (a + b > c and b + c > a and a + c > b)
Print "valid"
else
Print "invalid"
end if
valid
invalid
error
2 3 5
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer n = 45
String s = "none"
if (n mod 3 == 0)
s = "fizz"
end if
if (n mod 5 == 0)
s = s + "buzz"
end if
Print s
buzz
fizz
fizzbuzz
nonebuzz
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer n = 25
String s = "none"
if (n mod 3 == 0)
s = "fizz"
end if
if (n mod 5 == 0)
s = s + "buzz"
end if
Print s
fizzbuzz
nonebuzz
buzz
none
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer f = 0, b = 0, fb = 0
for (each i from 1 to 30)
if (i mod 15 == 0)
fb = fb + 1
else if (i mod 3 == 0)
f = f + 1
else if (i mod 5 == 0)
b = b + 1
end if
end for
Print f, b, fb
8 4 2
10 4 2
10 6 2
8 6 2
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 12, b = 18, c = 30
if (a > b)
if (a > c)
Print a
else
Print c
end if
else
if (b > c)
Print b
else
Print c
end if
end if
30
18
12
60
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 7
if (x mod 2 == 1)
x = x * 3
else
x = x / 2
end if
if (x > 20)
x = x - 1
else
x = x + 1
end if
Print x
22
20
21
4
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer s = 85, a = 92
String r
if (s >= 80)
if (a >= 90)
r = "Eligible with scholarship"
else
r = "Eligible"
end if
else
r = "Not eligible"
end if
Print r
Eligible
Not eligible
Nothing
Eligible with scholarship
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer count = 0
for (each a from 1 to 10)
for (each b from 1 to 10)
if (a < b AND (a + b) mod 5 == 0)
count = count + 1
end if
end for
end for
Print count
9
10
18
8
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 3, y = 0
if (x > 2)
y = y + 1
end if
if (x > 1)
y = y + 2
else if (x > 0)
y = y + 4
end if
if (x > 4)
y = y + 8
end if
Print y
7
11
1
3
Sign up free to see the answer and a step-by-step explanation.