Question 11
EasyWhat is the output of this pseudocode?
Integer a[] = {7, 3, 9, 2, 6}
Integer m = a[0]
for (each i from 1 to 4)
if (a[i] < m)
m = a[i]
end if
end for
Print m
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 a[] = {7, 3, 9, 2, 6}
Integer m = a[0]
for (each i from 1 to 4)
if (a[i] < m)
m = a[i]
end if
end for
Print m
6
2
7
3
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer a[] = {1, 2, 3, 4}, t
for (each i from 0 to 1)
t = a[i]
a[i] = a[3 - i]
a[3 - i] = t
end for
Print a[0]
2
4
1
3
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer a[] = {10, 20, 30}
a[1] = a[0] + a[2]
Print a[1]
40
20
50
60
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer a[] = {4, 8, 6, 2}, s = 0
for (each i from 0 to 3)
s = s + a[i]
end for
Print s / 4
20
6
5
4
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer a[] = {4, 9, 1, 9}, pos = -1
for (each i from 0 to 3)
if (a[i] == 9 and pos == -1)
pos = i
end if
end for
Print pos
3
-1
2
1
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a[] = {2, 7, 4, 9, 6}, count = 0
for (each i from 0 to 4)
if (a[i] mod 2 == 0)
count = count + 1
end if
end for
Print count
12
5
3
2
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer a[] = {3, 8, 5, 6}
Integer first = a[0], second = -1
for (each i from 1 to 3)
if (a[i] > first)
second = first
first = a[i]
else if (a[i] > second)
second = a[i]
end if
end for
Print second
6
5
3
8
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a[] = {1, 2, 3, 4}
Integer t = a[0]
for (each i from 0 to 2)
a[i] = a[i + 1]
end for
a[3] = t
Print a[3]
3
2
4
1
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer a[] = {1, 2, 3, 4}
for (each i from 1 to 3)
a[i] = a[i] + a[i - 1]
end for
Print a[3]
10
7
6
4
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Integer m[2][2] = {{1, 2}, {3, 4}}
Print m[1][0] + m[0][1]
6
3
5
4
Sign up free to see the answer and a step-by-step explanation.