Skip to content

Row sums of a matrix

C# nested loops

Flowchart (ISO 5807)

StartInput a, ni = 0, n − 1, 1s = 0j = 0, n − 1, 1s = s + a[i][j]Output sEndFigure 1 — Program.RowSums

Source code

C#
class Program {
    static void RowSums(int[][] a, int n) {
        for (int i = 0; i < n; i++) {
            int s = 0;
            for (int j = 0; j < n; j++) {
                s = s + a[i][j];
            }
            System.Console.WriteLine(s);
        }
    }
}

The editor opens with this code — change it and the chart redraws.

Language
C#
Constructs
nested loops
Topic
Loops
Formats
Word, Visio, draw.io, PDF, SVG

Related examples