PHP,
pasted
on May 29:
|
<?php
$score=array(80,90,90,99,78);
$total=0;
for ($a=0; $a< count($score); $a++) {
$total+=$score[$a];
}
$avg = $total/count($score);
echo ("score $score[0], $score[1], $score[2], $score[3], $score[4] <br>");
echo ("total $total, average $avg <br>");
?>
|
Output:
|
score 80, 90, 90, 99, 78 <br>total 437, average 87.4 <br>
|
|