Question 31
MediumWhat will be the output of the following pseudocode?
Integer c = 0
for (each i from 1 to 5)
for (each j from i to 5)
c = c + 1
end for
end for
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 will be the output of the following pseudocode?
Integer c = 0
for (each i from 1 to 5)
for (each j from i to 5)
c = c + 1
end for
end for
Print c
15
25
10
20
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 2
for (each i from 1 to 4)
if (i mod 2 == 1)
x = x + i
else
x = x * i
end if
end for
Print x
40
36
24
18
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer i = 1, count = 0
while (i <= 100)
i = i * 3
count = count + 1
end while
Print count
4
5
3
6
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer total = 0
for (each i from 1 to 10)
if (i == 7)
break
end if
if (i mod 2 == 0)
continue
end if
total = total + i
end for
Print total
9
16
15
25
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a = 0, b = 1, c, i
for (each i from 1 to 8)
c = a + b
a = b
b = c
end for
Print a
8
34
21
13
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer n = 1234, r = 0
while (n > 0)
r = r * 10 + n mod 10
n = n / 10
end while
Print r + 1
10
4321
1235
4322
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer count = 0, i, j
for (each i from 1 to 5)
for (each j from i to 5)
count = count + 1
end for
end for
Print count
20
25
15
10
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
while (i <= 100)
s = s + i
i = i * 3
end while
Print s
40
364
81
121
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer n = 36, d, c = 0
for (each d from 1 to n)
if (n mod d == 0)
c = c + 1
end if
end for
Print c
36
8
6
9
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer x = 100, steps = 0
while (x != 1)
if (x mod 2 == 0)
x = x / 2
else
x = 3 * x + 1
end if
steps = steps + 1
end while
Print steps
17
26
25
24
Sign up free to see the answer and a step-by-step explanation.