Diagram Desk

Sum from 1 to N flowchart

The most basic loop: add 1 through N. It shows keeping a running total and a counter apart, and how a loop condition becomes a decision.

The diagram

StartRead Nsum ← 0, k ← 1k ≤ N ?sum ← sum + kk ← k + 1Print sumEndyesno
Flowchart · 8 shapes

Reading it step by step

  • 1. Start at 'Start'.
  • 2. 'Read N' is an input or output. Next: 'sum ← 0, k ← 1'.
  • 3. 'sum ← 0, k ← 1' is a processing step. Next: 'k ≤ N ?'.
  • 4. Decide 'k ≤ N ?': if 'yes', go to 'sum ← sum + k'; if 'no', go to 'Print sum'.
  • 5. 'sum ← sum + k' is a processing step. Next: 'k ← k + 1'.
  • 6. 'k ← k + 1' is a processing step. Next: 'k ≤ N ?'.
  • 7. 'Print sum' is an input or output. Next: 'End'.
  • 8. End at 'End'.

Shape by shape

ShapeSymbolConnections
StartTerminator→ Read N
Read NInput/output→ sum ← 0, k ← 1 · ← Start
sum ← 0, k ← 1Process→ k ≤ N ? · ← Read N
k ≤ N ?Decision→ sum ← sum + k(yes), Print sum(no) · ← sum ← 0, k ← 1, k ← k + 1
sum ← sum + kProcess→ k ← k + 1 · ← k ≤ N ?
k ← k + 1Process→ k ≤ N ? · ← sum ← sum + k
Print sumInput/output→ End · ← k ≤ N ?
EndTerminator← Print sum

Symbols used here

SymbolMeaning
TerminatorWhere the flow starts or ends; a rounded rectangle.
ProcessOne action such as a calculation; a rectangle.
DecisionA question whose answer picks the next path; a diamond.
Input/outputData comes in or goes out; a parallelogram.
Flow lineThe order of steps, in the arrow direction.

All flowchart symbols and how to draw

Diagram text

Paste this text into the editor to get the same picture, then change the names to fit your own work.

# Sum from 1 to N flowchart
flowchart TD
  s(["Start"])
  a[/"Read N"/]
  b["sum ← 0, k ← 1"]
  c{"k ≤ N ?"}
  d["sum ← sum + k"]
  e["k ← k + 1"]
  f[/"Print sum"/]
  z(["End"])
  s --> a
  a --> b
  b --> c
  c -->|yes| d
  d --> e
  e --> c
  c -->|no| f
  f --> z

More flowchart examples

All SeewolLabs tools