3. (a) A PHP function is defined as follows: function planets ($arr) { if ($arr [1]) { print "Mercury"; } else { for ($i=0; $i <= $arr [2]; $i++) {print $arr [3] [$i]; } } print count ($arr); } Recall that array $arr can be defined using a statement of the form $arr = array (...);

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question
(iii)
Give an array $arr such that planets ($arr) prints
Earth Jupiter Saturn
Note: the for loop must do three iterations in case (iii).
- 6-
(iv)
For this case, what is the output of the instruction
print count ($arr);
Transcribed Image Text:(iii) Give an array $arr such that planets ($arr) prints Earth Jupiter Saturn Note: the for loop must do three iterations in case (iii). - 6- (iv) For this case, what is the output of the instruction print count ($arr);
3.
(a)
A PHP function is defined as follows:
function planets ($arr) {
if ($arr [1]) {
print "Mercury";
}
else {
for ($i=0; $i <= $arr [2]; $i++)
{print $arr [3] [$i];
}
}
print count ($arr);
}
Recall that array $arr can be defined using a statement of the form:
$arr
=
array (...);
(i)
Give an array $arr such that planets ($arr) prints
Mercury
For this case, what is the output of the instruction
print count ($arr);
Give an array $arr such that planets ($arr) prints
Venus
(ii)
Transcribed Image Text:3. (a) A PHP function is defined as follows: function planets ($arr) { if ($arr [1]) { print "Mercury"; } else { for ($i=0; $i <= $arr [2]; $i++) {print $arr [3] [$i]; } } print count ($arr); } Recall that array $arr can be defined using a statement of the form: $arr = array (...); (i) Give an array $arr such that planets ($arr) prints Mercury For this case, what is the output of the instruction print count ($arr); Give an array $arr such that planets ($arr) prints Venus (ii)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning