Largest of three numbers
A worked example to adapt. Rename steps, add branches and owners to match how your team actually works.
Mermaid source for this diagram
flowchart TD
s(["Start"])
in[/"Read A, B, C"/]
d1{"A > B?"}
d2{"A > C?"}
d3{"B > C?"}
pa[/"Print A is largest"/]
pc[/"Print C is largest"/]
pb[/"Print B is largest"/]
e(["End"])
s --> in
in --> d1
d1 -->|Yes| d2
d1 -->|No| d3
d2 -->|Yes| pa
d2 -->|No| pc
d3 -->|Yes| pb
d3 -->|No| pc
pa --> e
pc --> e
pb --> ePaste into any Markdown tool that renders Mermaid, such as GitHub.
About this flowchart to find the largest of three numbers
Finding the largest of three numbers is a standard first exercise in flowcharts and programming because it practices nested decisions: the answer to the first comparison decides which comparison you make next.
The flowchart reads three numbers, A, B and C. It first compares A with B. If A is larger, the only remaining question is whether A is also larger than C. If B is larger (or equal), the question becomes whether B is larger than C. Every path makes exactly two comparisons and ends with one output, so the chart has three output boxes and one end.
When two numbers are equal, this version still prints a correct largest value: for A = B = 5 and C = 2, the first test is No, then B > C is Yes, so it prints B, which is 5. If your assignment needs a message for equal values, add a separate decision before the comparisons.
Step by step
- Start. Begin with the terminator oval.
- Input. Read the three numbers into A, B and C. Inputs use the parallelogram symbol.
- First comparison. Is A greater than B? This splits the chart into two halves.
- Second comparison, Yes side. Is A greater than C? Yes prints A; No prints C.
- Second comparison, No side. Is B greater than C? Yes prints B; No prints C.
- Output and end. Print the result and stop. All three output boxes lead to the same end oval.
How to make it in flow-chart.io
- Start from the example. Press "Use this template" to open this exact largest-of-three flowchart in the editor, or edit the text in the generator box and press Generate for a free preview without signing up.
- Match your program. Rename the input, process and output boxes so they use the same variable names as your code. Keep one action per box.
- Check every branch. Trace each diamond with a test value for the Yes exit and one for the No exit, and make sure both reach the end oval.
- Share or export. Share a read-only view link with a classmate or reviewer. Downloads as PNG, SVG or PDF are part of Flow Pro (see pricing).
Tips
- Trace it with A=7, B=3, C=9: A > B is Yes, A > C is No, so it prints C (9). Correct.
- Trace it with A=2, B=8, C=5: A > B is No, B > C is Yes, so it prints B (8). Correct.
- Pseudocode: read A, B, C; if A > B then (if A > C then print A else print C) else (if B > C then print B else print C).
- An alternative uses a variable: max = A; if B > max then max = B; if C > max then max = C; print max. It needs two decisions in a row instead of a nested pair and extends easily to more numbers.
- Label both exits of every diamond; marking which side is Yes is the most common thing teachers deduct for.
Frequently asked questions
- How many decisions does the largest-of-three flowchart need?
- Three diamonds in the nested version (each path passes through two), or two in the version that keeps a running max variable.
- What happens if two numbers are equal?
- The flowchart still prints a value equal to the largest. If you need to report ties, add a decision that checks for equality first.
- How do I turn the flowchart into code?
- Each diamond becomes an if/else. In Python: if a > b: print(a if a > c else c) else: print(b if b > c else c). The structure is the same in C, Java or JavaScript.
- How do I extend it to N numbers?
- Use the running max version inside a loop: set max to the first number, then for each remaining number, if it is greater than max, replace max. Print max at the end.
- Can I edit this flowchart online?
- Yes. Press Use this template to open it in the editor with a free account, or try the text to flowchart tool to draw your own from typed steps without signing up.