Flowchart gallery
See which flowchart each code produces — loops, recursion, lambdas and more. Open any one fullscreen or edit it in the editor.
160 examples
Grade by score
PythonBranching · if / elif / else
Max of two
C++Branching · if / else
Even / odd
C#Branching · if / else
Sign of a number
JavaBranching · if / else if / else
Ternary operator
C++Branching · ?: → branching
Leap year
PythonBranching · compound condition
Day of week
C++Switch / case · switch + default
match / case
PythonSwitch / case · structural pattern matching
Letter grade
JavaSwitch / case · switch over ranges
case .. of
PascalSwitch / case · case in Pascal
switch-expression
C#Switch / case · C# switch
Sum 1..n
PythonLoops · for + range
Factorial (loop)
C++Loops · for with accumulation
Array sum
CLoops · for over an array
Reverse a number
C++Loops · while
do / while
C++Loops · post-condition loop
repeat .. until
PascalLoops · post-condition in Pascal
foreach
C#Loops · foreach over a collection
for-each
JavaLoops · for (T x : c)
for .. downto
PascalLoops · descending for
Factorial (recursion)
PythonRecursion · self-call → subroutine
Fibonacci numbers
PythonRecursion · double recursion
Exponentiation
C++Recursion · recursive power
Digit sum
JavaRecursion · recursion over digits
Named lambda
PythonLambdas · name = lambda → separate diagram
Lambda max
PythonLambdas · lambda + ternary
Lambda in C++
C++Lambdas · auto f = [](){…}
Greeting
PythonInput/Output · input → print
Sum from input
C++Input/Output · cin / cout
Doubling
PascalInput/Output · readln / writeln
Read a value
C#Input/Output · Console.ReadLine / WriteLine
Safe division
PythonExceptions · try / except
Parse a number
JavaExceptions · try / catch
Counter
JavaClasses & methods · class method
Reverse a string
C#Classes & methods · static method
Circle area
C++Classes & methods · class method
Bubble sort
PythonAlgorithms · nested loops + swap
Linear search
JavaAlgorithms · loop + return index
Primality test
C++Algorithms · loop with early return
Binary search
PythonAlgorithms · while + branching
FizzBuzz
PythonAlgorithms · loop + multiple conditions
GCD (Euclid)
PascalAlgorithms · while + I/O
Power (loop)
C#Algorithms · while accumulation
Insertion sort
C++Algorithms · insertion sort
Selection sort
JavaAlgorithms · selection sort
Sieve of Eratosthenes
C++Algorithms · primes up to n
Palindrome
PythonAlgorithms · string palindrome
Reverse a string
C#Algorithms · reverse a string
Count vowels
PythonLoops · how many vowels
Towers of Hanoi
PythonRecursion · classic recursion
LCM
CAlgorithms · least common multiple
To binary
C++Algorithms · decimal → binary
Max in an array
CLoops · largest element
Sum of evens
PascalLoops · evens up to n
Digit count
PascalLoops · how many digits
Category by age
JavaScriptBranching · if / else
Sign of a number
TypeScriptBranching · if / else if + types
Grade by score
PHPBranching · if / elseif / else
Grade by score
GoBranching · if / else if / else
Size by number
TypeScriptSwitch / case · switch + default
Day of week
GoSwitch / case · switch + default
Color by code
PHPSwitch / case · match expression
Day name
JavaScriptSwitch / case · switch + default
Size by number
PHPSwitch / case · switch + default
Array sum
JavaScriptLoops · for-of
Slice sum
GoLoops · for + range
Sum of items
PHPLoops · foreach
Reverse a number
JavaScriptLoops · while
Factorial (loop)
JavaScriptLoops · for with accumulation
Array sum
TypeScriptLoops · for + types
Reverse a number
TypeScriptLoops · while
Reverse a number
GoLoops · for (while form)
Factorial (recursion)
TypeScriptRecursion · recursion
Fibonacci numbers
GoRecursion · double recursion
Exponentiation
JavaScriptRecursion · recursive power
Digit sum
PHPRecursion · recursion over digits
Arrow function
JavaScriptLambdas · name = arrow → separate diagram
Arrow function
TypeScriptLambdas · arrow + types
Closure
PHPLambdas · closure assigned to name
Greeting
JavaScriptInput/Output · prompt → console.log
Greeting
TypeScriptInput/Output · prompt → console.log
Sum from input
GoInput/Output · fmt.Scan / Println
Greeting
PHPInput/Output · readline → echo
Safe division
JavaScriptExceptions · try / catch
Parse a number
TypeScriptExceptions · try / catch
Safe division
GoExceptions · returning an error
Safe division
PHPExceptions · try / catch
Counter
TypeScriptClasses & methods · class method
Circle area
PHPClasses & methods · class method
Counter
JavaScriptClasses & methods · class method
Circle area
GoClasses & methods · method with receiver
Account deposit
GoClasses & methods · method with receiver
Linear search
JavaScriptAlgorithms · loop + return index
Primality test
GoAlgorithms · loop with early return
Bubble sort
JavaScriptAlgorithms · nested loops + swap
Primality test
TypeScriptAlgorithms · loop with early return
Binary search
TypeScriptAlgorithms · while + branching
GCD (Euclid)
GoAlgorithms · while + swap
GCD (Euclid)
PHPAlgorithms · while loop
Linear search
PHPAlgorithms · loop + return index
Quadratic equation
PascalBranching · discriminant, if / else
Multiplication table
PascalLoops · nested for loops
Armstrong number
PythonLoops · sum of digit cubes
Perfect number
C++Loops · sum of divisors
Prime factorization
PythonAlgorithms · division loop
Bisection method
C++Algorithms · numeric method, while
Pi (Leibniz series)
CLoops · alternating series
Array average
JavaLoops · sum / count
Array minimum
GoAlgorithms · find smallest
Matrix transpose
C++Loops · nested loops, swap
Main diagonal sum
JavaLoops · loop over diagonal
Swap two variables
PascalInput/Output · via temp variable
Quick sort
C++Recursion · divide and conquer
Newton's method
C++Algorithms · loop + update
Trapezoidal rule
PascalAlgorithms · numeric integration
Rectangle rule
JavaAlgorithms · numeric integration
Taylor series for e^x
C#Algorithms · series accumulation
Taylor series for sin
PythonAlgorithms · alternating series
Horner's scheme
C++Algorithms · polynomial evaluation
Matrix multiplication
JavaLoops · nested loops
Symmetric matrix check
C++Loops · nested loops
Maximum in a matrix
PascalLoops · nested loops
Row sums of a matrix
C#Loops · nested loops
Anti-diagonal sum
GoLoops · loop over diagonal
Word count
TypeScriptLoops · loop over characters
Substring search
C++Algorithms · nested loops
Character frequency
JavaLoops · counting in an array
Anagram check
C#Algorithms · character counting
Caesar cipher
PascalAlgorithms · character shift
Count uppercase letters
JavaScriptLoops · loop + condition
Is all digits
PHPLoops · loop + condition
Collatz conjecture
PythonLoops · while + branching
Digital root
C++Loops · nested loops
Amicable numbers
JavaAlgorithms · sum of divisors
Triangular number
PascalLoops · sum accumulation
Sum of proper divisors
C#Loops · loop + condition
Count divisors
GoLoops · loop + counter
Palindrome number
C++Algorithms · reversing a number
Fast exponentiation
JavaAlgorithms · binary exponentiation
To hexadecimal
C++Algorithms · loop + array
Solving a linear equation
PascalBranching · if / else if / else
Quadratic discriminant
C#Branching · if / else if / else
Power (recursion)
C++Recursion · recursion
Sum 1..n (recursion)
JavaRecursion · recursion
GCD (recursion)
PythonRecursion · Euclid recursion
String reverse (recursion)
TypeScriptRecursion · recursion
Digit count
PascalRecursion · recursion over digits
Ackermann function
C++Recursion · double recursion
Celsius to Fahrenheit
PythonInput/Output · formula + output
Simple interest
PascalInput/Output · formula + output
Compound interest
JavaLoops · loop over years
Minimum of three
CBranching · sequential ifs
Sort three numbers
CBranching · swap via if
Triangle area (Heron)
C#Input/Output · Heron's formula
Rectangle perimeter and area
PHPInput/Output · two formulas
Array-based stack
JavaClasses & methods · push / pop
Array-based queue
C++Classes & methods · enqueue / dequeue
Count occurrences
TypeScriptLoops · loop + counter
Remove duplicates
PythonAlgorithms · nested loops
Second largest element
GoAlgorithms · two maxima