Code Logo

Find Larger Number

Published at19 Apr 2026
Searching & Sorting Easy 5 views
Like0

Picking the bigger of two values is a classic decision-making step in coding. Whether you''re comparing high scores in a game or finding the larger of two prices, Find Larger Number focuses on this simple but essential logic.

The task is simple: you have two numbers, and you need to determine which one is the maximum. If the numbers are the same, either one can be considered the larger one since they are equal.

For example, if you are given 7 and 12, the answer is clearly 12. If you are given 9 and 9, the answer is just 9. Your algorithm should take any two integers and return the one that represents the higher value.

Learn about our pseudocode specification
Guide

Example Input & Output

Example 1
Input
a = 7, b = 7
Output
7
Explanation

Both values are equal, so the result is 7.

Example 2
Input
a = 3, b = 12
Output
12
Explanation

12 is larger than 3.

Example 3
Input
a = 9, b = 4
Output
9
Explanation

9 is larger than 4.

Algorithm Flow

Recommendation Algorithm Flow for Find Larger Number
Recommendation Algorithm Flow for Find Larger Number

Solution Approach

Start by reading the two integers.

After that, compare the first number with the second number.

If the first number is greater than or equal to the second number, print the first number.

If that condition is false, print the second number instead.

This works because one of the two numbers must be the larger value, and if they are equal, either one is a correct result.

Best Answers

Pseudocode - Approach 1
program find_larger_number
dictionary
   a, b: integer
algorithm
   input(a, b)
   if a >= b then
      output(a)
   else
      output(b)
   endif
endprogram