Code Logo

Find Smallest of Three

Published at19 Apr 2026
Searching & Sorting Easy 0 views
Like0

Sometimes you have multiple options and you need to pick the smallest one—like finding the lowest price while shopping or the shortest route to a destination. In Find Smallest of Three, your job is to compare three different numbers and identify which one is the minimum.

You’ll need to look at all three values and decide which one stands as the smallest. This involves a simple comparison logic where you check each number against the others to find the one that is less than or equal to everyone else.

Imagine you have the numbers 10, 5, and 8. You would compare them and see that 5 is the smallest of the group. Your program should be able to look at any three numbers and pick out the one that stays at the bottom of the list.

Learn about our pseudocode specification
Guide

Example Input & Output

Example 1
Input
a = -1, b = 4, c = 0
Output
-1
Explanation

-1 is the smallest value.

Example 2
Input
a = 5, b = 2, c = 9
Output
2
Explanation

2 is the smallest among the three values.

Example 3
Input
a = 7, b = 7, c = 7
Output
7
Explanation

All values are equal, so the smallest is 7.

Algorithm Flow

Recommendation Algorithm Flow for Find Smallest of Three
Recommendation Algorithm Flow for Find Smallest of Three

Solution Approach

Identifying the minimum among three values requires a series of comparisons. We can approach this by checking one number against the others, or by assuming one is the smallest and updating our assumption as we go along.

dictionary
   a, b, c, min_val: integer
algorithm
   input(a, b, c)
   min_val <- a
   if b < min_val then min_val <- b endif
   if c < min_val then min_val <- c endif
   output(min_val)

In this logic, we initialize min_val with the first number, a. Then we sequentially compare it with b and c. If either b or c is smaller than our current minimum, we update min_val to hold that new value. This sequential comparison ensures we find the true minimum among all three candidates by the time the algorithm finishes.

Best Answers

Pseudocode - Approach 1
program find_smallest_of_three
dictionary
   a, b, c, smallest: integer
algorithm
   input(a, b, c)
   smallest <- a
   if b < smallest then
      smallest <- b
   endif
   if c < smallest then
      smallest <- c
   endif
   output(smallest)
endprogram