ProgrammingEasyTCS NQT · Wipro pattern
What will be the output of the following pseudocode? (/ is integer division.)
What will be the output of the following pseudocode? (/ is integer division.)
Integer a = 7, b = 3 a = a * b - a / b Print a
- A. 19
- B. 18.67
- C. 21
- D. 14
Correct answer: A. 19
* and / bind tighter than − and are applied left to right: a * b = 21 and a / b = 2 (integer division drops the fraction). 21 − 2 = 19. 18.67 uses real division, which integer variables cannot hold.
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? Integer c = 0 for (i = 1 to 20) if (i mod 3 == 0 or i mod 5 == 0) c = c + 1 end if…
- What will be the output of the following pseudocode? (/ is integer division.) Integer n = 2405, c = 0, s = 0 while (n > 0) s = s + n mod…
- What will be the output of the following pseudocode? Integer c = 0 for (i = 1 to 4) for (j = 1 to 4) if (j > i) break end if c = c + j end…
- What will be the output of the following pseudocode? (&, |, ^ are bitwise AND, OR, XOR; << is a left shift; precedence as in C: << binds…
- What will be the output of the following pseudocode? Function f(Integer n) if (n <= 1) return 1 end if return f(n - 1) + 2 f(n - 2) End…
- What will be the output of the following pseudocode? (Strings are indexed from 0.) String s = "PSEUDOCODE" Integer v = 0 for (i = 0 to…