Question 51
MediumWhat is the output of this pseudocode?
Integer i = 1, c = 0
while (i < 1000)
i = i * 2
c = c + 1
end while
Print 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 i = 1, c = 0
while (i < 1000)
i = i * 2
c = c + 1
end while
Print c
1000
10
9
11
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer i, s = 0
for (each i from 10 down to 1 step 3)
s = s + i
end for
Print s
21
55
22
19
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer row, col
for (each row from 1 to 3)
for (each col from 1 to 3)
if (col > row)
Print 0
else
Print row
end if
end for
end for
1 0 0 2 2 0 3 3 3
0 0 1 0 2 2 3 3 3
1 2 3 2 3 0 3 0 0
1 1 1 2 2 2 3 3 3
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer n = 6, f = 1, s = 0, i
for (each i from 1 to n)
f = f * i
s = s + f
end for
Print s
873
33
153
720
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer s = 0
for (each i from 1 to 3)
for (each j from 1 to 3)
if (i != j)
s = s + i * j
end if
end for
end for
Print s
36
25
22
14
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer n = 6, steps = 0
while (n != 1)
if (n mod 2 == 0)
n = n / 2
else
n = 3 * n + 1
end if
steps = steps + 1
end while
Print steps
9
16
8
6
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 48, y = 36, r
while (y != 0)
r = x mod y
x = y
y = r
end while
Print x
12
4
36
6
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 n from 2 to 20)
Boolean prime = true
for (each d from 2 to n - 1)
if (n mod d == 0)
prime = false
end if
end for
if (prime)
count = count + 1
end if
end for
Print count
10
7
8
9
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer k = 1, p = 0
while (k * k <= 50)
p = p + 1
k = k + 1
end while
Print p
8
7
6
50
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer s = 0
for (each i from 1 to 100)
if (i mod 3 == 0 OR i mod 5 == 0)
s = s + i
end if
end for
Print s
2318
2418
1050
1683
Sign up free to see the answer and a step-by-step explanation.