nerdexam
National_Instruments

200-500 · Question #212

How many times will the function counter() be executed in the following code? function counter($start, &$stop) { if ($stop > $start) { return; } counter($start--, ++$stop); } $start = 5; $stop = 2…

The correct answer is C. 5. See the full explanation below for the reasoning.

Question

How many times will the function counter() be executed in the following code? function counter($start, &$stop) { if ($stop > $start) { return; } counter($start--, ++$stop); } $start = 5; $stop = 2; counter($start, $stop);

Options

  • A3
  • B4
  • C5
  • D6

How the community answered

(50 responses)
  • A
    2% (1)
  • B
    10% (5)
  • C
    82% (41)
  • D
    6% (3)

Community Discussion

No community discussion yet for this question.

Full 200-500 Practice