Question 11
EasyWhat does the following pseudocode print?
Function power(Integer b, Integer e)
if (e == 0)
return 1
end if
return b * power(b, e - 1)
End Function
Print power(3, 3)
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?
Function power(Integer b, Integer e)
if (e == 0)
return 1
end if
return b * power(b, e - 1)
End Function
Print power(3, 3)
9
81
6
27
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Function fib(Integer n)
if (n < 2)
return n
end if
return fib(n - 1) + fib(n - 2)
End Function
Print fib(7)
7
13
21
8
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Function maxOf(Integer a, Integer b)
if (a > b)
return a
end if
return b
End Function
Print maxOf(maxOf(3, 9), 5)
5
9
17
3
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Function isEven(Integer n)
return (n mod 2 == 0)
End Function
Print isEven(7)
1
7
true
false
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Function digits(Integer n)
if (n < 10)
return 1
end if
return 1 + digits(n / 10)
End Function
Print digits(50213)
4
11
5
50213
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Function rev(Integer n, Integer r)
if (n == 0)
return r
end if
return rev(n / 10, r * 10 + n mod 10)
End Function
Print rev(472, 0)
13
0
472
274
Sign up free to see the answer and a step-by-step explanation.
What does the following pseudocode print?
Function gcd(Integer a, Integer b)
if (b == 0)
return a
end if
return gcd(b, a mod b)
End Function
Print gcd(81, 27)
9
27
81
3
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Function addTen(Integer x)
x = x + 10
return x
End Function
Integer a = 5
addTen(a)
Print a
15
5
0
10
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Function g(Integer n)
if (n == 0)
return 0
end if
return n mod 2 + g(n / 2)
End Function
Print g(13)
4
6
13
3
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Function h(Integer n)
if (n <= 0)
return 0
end if
return n + h(n - 2)
End Function
Print h(7)
7
28
16
15
Sign up free to see the answer and a step-by-step explanation.