Q:

Your task is to develop a small part of spreadsheet software

0

Your task is to develop a small part of spreadsheet software.
Write a PHP program which adds up columns and rows of given table as shown in the following figure:

Pictorial Presentation:

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

 $m) {
            $m = (int)$m;
            $arr[$i][$j] = $m;
            $arr[$i][$n] += $m;
            $arr[$n][$j] += $m;
        }
    }
    $arr[$n][$n] = array_sum($arr[$n]);
    echo "The table with sum of rows and columns:\n";
 
    for ($i = 0; $i <= $n; $i++) {
        for ($j = 0; $j <= $n; $j++) {
            printf('%5d', $arr[$i][$j]);
        }
        echo PHP_EOL;
    }
}
?>

Sample Input:
4
25 69 51 26
68 35 29 54
54 57 45 63
61 68 47 59
0

Sample Output:

The table with sum of rows and columns:
   25   69   51   26  171
   68   35   29   54  186
   54   57   45   63  219
   61   68   47   59  235
  208  229  172  202  811

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now