Question 41
MediumWhat does the following pseudocode print?
Integer i, j
for (each i from 1 to 4)
for (each j from 1 to i)
if (j == 3)
break
end if
Print j
end for
end for
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 i, j
for (each i from 1 to 4)
for (each j from 1 to i)
if (j == 3)
break
end if
Print j
end for
end for
1 1 2 1 2 1 2 3
1 2 1 2
1 1 2 1 2 3 1 2 3 4
1 1 2 1 2 1 2
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer s = 0, i
for (each i from 1 to 20)
if (i mod 3 == 0 and i mod 5 == 0)
s = s + 100
else if (i mod 3 == 0)
s = s + 1
else if (i mod 5 == 0)
s = s + 10
end if
end for
Print s
126
145
136
135
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer n = 5, i, j, total = 0
for (each i from 1 to n)
for (each j from 1 to n)
if (i == j or i + j == n + 1)
total = total + 1
end if
end for
end for
Print total
8
10
9
5
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer a = 48, b = 18, t
while (b != 0)
t = a mod b
a = b
b = t
end while
Print a
6
18
3
2
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer k = 0, i = 10
do
k = k + i
i = i - 3
while (i > 0)
Print k, i
22 1
10 7
22 -2
18 -2
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer p = 1, i
for (each i from 1 to 10)
p = (p * 2) mod 7
end for
Print p
1
2
4
1024
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer n = 7, i, j = 0
for (each i from 1 to n)
if (i mod 2 == 0)
continue
end if
j = j + i
end for
Print j
28
7
12
16
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer x = 0, i, j
for (each i from 1 to 3)
for (each j from 1 to 3)
x = x + i * j
end for
end for
Print x
27
36
45
18
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer n = 10, a = 0
while (n > 0)
a = a + n
n = n - 2
if (a > 20)
break
end if
end while
Print a, n
18 4
24 4
24 2
30 0
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer n = 153, s = 0, d, t
t = n
while (t > 0)
d = t mod 10
s = s + d * d * d
t = t / 10
end while
if (s == n)
Print "Armstrong"
else
Print s
end if
Not Armstrong
153
9
Armstrong
Sign up free to see the answer and a step-by-step explanation.