0
Rishi Agnihotri
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
Select Programming Language
Submit Answer
0 Answers
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))