Write a PHP program to compute the sum of the elements of an given array of integers.
<?php function test($a1) { return $a1[0] + $a1[1] + $a1[2] + $a1[3] + $a1[4]; } echo test([10, 20, 30, 40, 50]) . "\n"; echo test([10, 20, -30, -40, 50]) . "\n";
Sample Output:
150 10
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer