Question 71
HardWhat will be the output of the following pseudocode?
Integer n = 7, f1 = 1, f2 = 1, i
for (each i from 3 to n)
f2 = f1 + f2
f1 = f2 - f1
end for
Print f2
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 will be the output of the following pseudocode?
Integer n = 7, f1 = 1, f2 = 1, i
for (each i from 3 to n)
f2 = f1 + f2
f1 = f2 - f1
end for
Print f2
13
7
8
21
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer n = 1000, c = 0
while (n >= 1)
n = n / 3
c = c + 1
end while
Print c
6
333
8
7
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer i, j, total = 0
for (each i from 1 to 5)
for (each j from 1 to 5)
if (i == j)
continue
end if
if (i + j == 6)
break
end if
total = total + 1
end for
end for
Print total
9
15
10
20
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer n = 10, s = 0, k
for (each k from 1 to n)
s = s + k * (n - k + 1)
end for
Print s
385
220
550
110
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 0, i
for (each i from 1 to 10)
if (i mod 2 == 0)
x = x + i
else
x = x - i
end if
end for
Print x
55
5
-5
0
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer n = 64, c = 0, i
for (i = 1; i < n; i = i * 2)
c = c + 1
end for
Print c
5
7
6
64
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer a = 1, b = 1, n = 0
while (b < 1000)
Integer t = b
b = a + b
a = t
n = n + 1
end while
Print n, b
15 987
15 1597
14 1597
16 1597
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer s = 0, i = 1
repeat
s = s + i * i
i = i + 2
until (i > 9)
Print s
165
285
84
120
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer count = 0, n
for (each n from 1 to 50)
Integer m = n, s = 0
while (m > 0)
s = s + m mod 10
m = m / 10
end while
if (s == 5)
count = count + 1
end if
end for
Print count
5
10
6
4
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer n = 9, i, j, c = 0
for (each i from 1 to n)
for (each j from 1 to n)
if (i * j <= n)
c = c + 1
end if
end for
end for
Print c
23
20
81
45
Sign up free to see the answer and a step-by-step explanation.