Largest of Three Numbers Flowchart
Flowchart to find largest of three numbers: read a, b and c, ask whether a beats both others, then compare b with c. With a trace table for 12, 45 and 30, pseudocode, and tested Python, C and Java code.
Flowchart to find largest of three numbers: read a, b and c, ask whether a beats both others, then compare b with c. With a trace table for 12, 45 and 30, pseudocode, and tested Python, C and Java code.
Study guide
A flowchart to find largest of three numbers needs no loop, just two well placed decisions. The first asks whether a is at least as big as both others; if not, the winner must be b or c, so a single comparison settles it.
Think of it as a knockout: once a is out, only one match is left.
a wins only if it is at least b and at least c. Using >= instead of > means ties still produce an answer.a lost, so the largest is b or c. One comparison decides between them.a, the largest value.b. We know a is not the unique largest and b >= c.c, which beat b after a was ruled out.Follow the flowchart with 12, 45 and 30. Each row is one decision diamond.
| Step | Diamond | With the numbers | Answer | Next step |
|---|---|---|---|---|
| 1 | a >= b and a >= c? | 12 >= 45 and 12 >= 30 | No | Go to b >= c? |
| 2 | b >= c? | 45 >= 30 | Yes | Print b (45) |
Two questions were enough. No input ever needs more than two.
READ a, b, c
IF a >= b AND a >= c THEN
PRINT "Largest is", a
ELSE IF b >= c THEN
PRINT "Largest is", b
ELSE
PRINT "Largest is", c
ENDIF
a, b, c = map(int, input().split())
if a >= b and a >= c:
largest = a
elif b >= c:
largest = b
else:
largest = c
print("Largest is", largest)
#include <stdio.h>
int main(void) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int largest;
if (a >= b && a >= c) {
largest = a;
} else if (b >= c) {
largest = b;
} else {
largest = c;
}
printf("Largest is %d\n", largest);
return 0;
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int largest;
if (a >= b && a >= c) {
largest = a;
} else if (b >= c) {
largest = b;
} else {
largest = c;
}
System.out.println("Largest is " + largest);
}
}
12 45 30
Largest is 45
All three programs were compiled and run with the input 12 45 30 before this page was published, and they print exactly the output shown. The programs store the winner in largest and print once, which does the same job as the three Print boxes.
a > b alone does not make a the largest: try 5, 3, 9. The first diamond must check both b and c.a > b and a > c and the input 7, 7, 2, the flowchart falls through and prints 2 if the second test is also strict. >= keeps ties safe.b >= a in the second diamond. It is not needed: once the first diamond said No, the largest is already b or c.First diamond: 8 >= 8 is true and 8 >= 3 is true, so the answer is Yes.
The output is Largest is 8. Because of >=, the tie between a and b causes no trouble.
Three diamonds. First ask a >= b?. On Yes, ask a >= c? (Yes prints a, No prints c). On No, ask b >= c? (Yes prints b, No prints c).
IF a >= b THEN
IF a >= c THEN PRINT a ELSE PRINT c
ELSE
IF b >= c THEN PRINT b ELSE PRINT c
ENDIF
It still asks only two questions on any one run, but the diagram has three diamonds and two Print c boxes, or one Print c box with two arrows into it.
Read the first number into max. Then loop: read the next number x, ask x > max?, and on Yes set max = x. Repeat until N numbers are read, then print max.
The new part is a loop, a flow line that goes back up to an earlier step, like in the for loop flowchart.
| Symbol | Shape to draw on paper | Where it appears here | Why |
|---|---|---|---|
| Terminator | Rounded box | Start and End | One entry and one exit, even though three paths lead to the end. |
| Input/output | Parallelogram | Read a, b, c and the three Print boxes | They move data into or out of the program. |
| Decision | Diamond | a >= b and a >= c? and b >= c? | Yes-or-no questions with two labelled exits each. |
| Flow line | Arrow | Every arrow | Arrows show the order. Here none of them points back up, so there is no loop. |
In the interactive diagram every step is a labelled card: the small word above each step names its kind (process, decision or data). When you draw this flowchart by hand, use the standard shapes in the table. The full list is on the flowchart symbols page.
Each link opens the editor with a prompt already filled in. Change the wording, then generate your own flowchart.
Download the Largest of Three Numbers Flowchart as a PNG or SVG, or open it in the studio to edit your own copy. To draw a similar flowchart from a description, use the flowchart generator; for notation and a step-by-step walkthrough, read how to make a flowchart; and browse more flowchart examples for related layouts.
Type any system, process, or schema in plain English. ChartCraft will draw it in seconds.