Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Zend 200-710 Exam - Topic 6 Question 72 Discussion

Actual exam question for Zend's 200-710 exam
Question #: 72
Topic #: 6
[All 200-710 Questions]

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);

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Kimberely
4 months ago
I thought it would be 6, but I see the mistake now.
upvoted 0 times
...
Laura
4 months ago
Wait, how does $start decrease if it's passed as a parameter?
upvoted 0 times
...
Mattie
4 months ago
Definitely 4, I checked the logic.
upvoted 0 times
...
Celia
4 months ago
I think it's 5 times, not 4.
upvoted 0 times
...
Julene
5 months ago
The function will be executed 4 times.
upvoted 0 times
...
Long
5 months ago
I feel like the answer might be 5, but I can't quite visualize how the recursion unfolds with those parameters.
upvoted 0 times
...
Yan
5 months ago
I'm a bit confused about the order of operations here. Does $start-- mean it decreases after the call?
upvoted 0 times
...
Lettie
5 months ago
I remember a similar question where we had to track recursive calls, and I think it was about 4 times for this one too.
upvoted 0 times
...
Thurman
5 months ago
I think the function will execute until $stop is greater than $start, but I'm not sure how the decrement and increment affect the counts.
upvoted 0 times
...
Weldon
5 months ago
This is a good example of a recursive function that can be tricky to reason about. I'll make sure to carefully trace the execution flow and keep track of the variable values to arrive at the correct answer.
upvoted 0 times
...
Cecilia
5 months ago
I'm not entirely sure about this one. The combination of the conditional and the increment/decrement operators is making it a bit challenging to visualize. I'll need to test this out with some sample values to be confident in my answer.
upvoted 0 times
...
Susana
5 months ago
Hmm, I'm a bit confused by the pre- and post-increment/decrement operators in the function call. I'll need to work through this step-by-step to make sure I understand what's happening.
upvoted 0 times
...
Marisha
5 months ago
This looks like a tricky recursive function question. I'll need to carefully trace the function calls to determine the number of times it's executed.
upvoted 0 times
...
Shaniqua
6 months ago
Okay, I think I've got it. The function will be called 4 times before the base case is reached and the recursion stops.
upvoted 0 times
...
Lindy
6 months ago
Hmm, I'm a bit confused on this one. I'll need to review the TOGAF concepts again to make sure I understand the difference between a building block, application, and solution architecture.
upvoted 0 times
...
Gail
10 months ago
Wait, is this a coding exam or a stand-up comedy routine? I'm feeling inspired to write some recursive jokes!
upvoted 0 times
...
Hayley
10 months ago
This is a tricky one! I bet the instructor is just trying to confuse us. Time to break out the whiteboard and some coffee!
upvoted 0 times
Stanton
9 months ago
C) 5
upvoted 0 times
...
Layla
9 months ago
B) 4
upvoted 0 times
...
Edna
10 months ago
A) 3
upvoted 0 times
...
...
Princess
11 months ago
D) 6 has to be the right answer. The function calls itself recursively, so it will keep going until the condition is no longer met.
upvoted 0 times
Erick
10 months ago
D) 6
upvoted 0 times
...
Sharee
10 months ago
C) 5
upvoted 0 times
...
Yolando
10 months ago
B) 4
upvoted 0 times
...
Irving
11 months ago
A) 3
upvoted 0 times
...
...
Deonna
11 months ago
Hmm, I'm not sure about this one. Let me think it through step-by-step. I'll try to solve it on paper to be sure.
upvoted 0 times
...
Gerald
11 months ago
I see, I think it's because the function is called recursively until $stop is greater than $start.
upvoted 0 times
...
Vilma
11 months ago
I believe it will be executed 5 times.
upvoted 0 times
...
Julio
11 months ago
I think the correct answer is C) 5. The function counter() will be executed 5 times because the loop continues until $stop is greater than $start.
upvoted 0 times
Evangelina
10 months ago
It's B) 4 because the function is called 4 times before the condition is met.
upvoted 0 times
...
Maddie
10 months ago
Really? I thought it was C) 5 too.
upvoted 0 times
...
Darell
10 months ago
No, it's actually B) 4.
upvoted 0 times
...
Socorro
10 months ago
I think the correct answer is C) 5.
upvoted 0 times
...
...
Gerald
11 months ago
I think the function will be executed 4 times.
upvoted 0 times
...

Save Cancel