Question 71
HardWhat is the output of this pseudocode?
Integer units = 320, bill
if (units <= 100)
bill = units * 3
else if (units <= 300)
bill = 300 + (units - 100) * 5
else
bill = 300 + 1000 + (units - 300) * 8
end if
Print bill
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 units = 320, bill
if (units <= 100)
bill = units * 3
else if (units <= 300)
bill = 300 + (units - 100) * 5
else
bill = 300 + 1000 + (units - 300) * 8
end if
Print bill
1300
1600
1460
2560
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer a = 3, b = 8
if (a > b)
if (a > 10)
Print "x"
end if
else
if (b > 10)
Print "y"
else
Print "z"
end if
end if
Nothing is printed
x
y
z
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer n = 28, s = 0, d
for (each d from 1 to n - 1)
if (n mod d == 0)
s = s + d
end if
end for
if (s == n)
Print "perfect"
else if (s > n)
Print "abundant"
else
Print "deficient"
end if
deficient
abundant
perfect
28
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer n = 12, s = 0, d
for (each d from 1 to n - 1)
if (n mod d == 0)
s = s + d
end if
end for
if (s == n)
Print "perfect"
else if (s > n)
Print "abundant"
else
Print "deficient"
end if
perfect
abundant
16
deficient
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer p = 1, q = 0, r = 1
if (p and q or r)
Print "A"
end if
if (p and (q or r))
Print "B"
end if
if (not p or q and r)
Print "C"
end if
B
A
A B
A B C
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer age = 17, hasId = 1, withParent = 0
if (age >= 18 and hasId == 1)
Print "enter"
else if (age >= 16 and withParent == 1)
Print "enter with parent"
else
Print "denied"
end if
denied
enter
enter denied
enter with parent
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 10
switch (x mod 4)
case 0: x = x + 1
case 1: x = x * 2
break
case 2: x = x - 3
case 3: x = x * 10
break
end switch
Print x
70
100
20
7
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 6, b = 4, c = 9
Integer m = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c)
Integer n = (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c)
Print m - n
13
3
2
5
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer t = 38, h = 85
if (t > 35)
if (h > 80)
Print "danger"
else
Print "hot"
end if
else if (h > 80)
Print "humid"
else
Print "fine"
end if
fine
hot
humid
danger
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer a = 0, b = 5
if (a != 0 and b / a > 1)
Print "x"
else if (a == 0 or b / a < 1)
Print "y"
end if
Print a + b
Division by zero error
x 5
y 5
5
Sign up free to see the answer and a step-by-step explanation.