ProgrammingModerateTCS NQT · Infosys · Accenture
What will be the output of the following pseudocode?
What will be the output of the following pseudocode?
function change(Integer x)
x = x + 10
return x * 2
end function
Integer a = 4, b
b = change(a) // pass by value
Print a, b- A. 4 28
- B. 14 28
- C. 4 14
- D. 14 14
Correct answer: A. 4 28
x is a copy, so a stays 4; the function returns (4 + 10) x 2 = 28.
Practise more Pseudocode and Code Tracing questionsPseudocode and Code Tracing: notes and key points
More Pseudocode and Code Tracing questions
- What will be the output of the following pseudocode? function triple(ref Integer x) // pass by reference x = x 3 end function Integer a =…
- What will be the output of the following pseudocode? Integer M[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, s = 0 for (each i from 0 to 2) s…
- What will be the output of the following pseudocode? Integer i = 10, c = 0 do i = i - 4 c = c + 1 while (i > 0) Print i, c
- What will be the output of the following pseudocode? function g(Integer n) if (n > 0) g(n - 1) Print n g(n - 2) end if end function g(3)
- What will be the output of the following pseudocode? Integer c = 0 for (i = 100; i > 1; i = i / 3) c = c + 1 end for Print c
- What will be the output of the following pseudocode? (All variables are integers.) Integer a = 9, b = 2 a = a b b = a / b a = a / b Print…