Find the Maximum of Three Numbers

0
Rishi Agnihotri
Rishi Agnihotri
Aug 11, 2026 10:15 PM 0 Answers Python
Member Since Aug 2026
Subscribed Subscribe Not subscribe
Flag(0)

Write a Python function find_max(a, b, c) that takes three numbers as input and returns the largest among them without using the built-in max() function.

Input: Three numbers a, b, c.
Output: The largest of the three numbers.
Constraints: Numbers can be integers or floats.
Example: find_max(10, 25, 15) -> 25

Explanation: Compare a, b, and c using conditional if-elif-else statements.
Complexity: Time: O(1), Space: O(1)

1 Subscribers
Rishi Agnihotri

Select Programming Language

Submit Answer
0 Answers
Sort By:

Python
def find_max(a, b, c):
    if a >= b and a >= c:
        return a
    elif b >= a and b >= c:
        return b
    else:
        return c

# Example usage
print(find_max(10, 25, 15))
0