Skip to content

Array sum

C for over an array

Same task in: JavaScriptTypeScript

Flowchart (ISO 5807)

StartInput a[], ns = 0i = 0, n − 1, 1s = s + a[i]Return sEndFigure 1 — sum

Source code

C
int sum(int a[], int n) {
    int s = 0;
    for (int i = 0; i < n; i++) {
        s += a[i];
    }
    return s;
}

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

Language
C
Constructs
for over an array
Topic
Loops
Formats
Word, Visio, draw.io, PDF, SVG

Related examples