Write a function which takes three integers as arguments, and returns the maximum of the three. The main() function then tests this function appropriately.
Question
Write a function which takes three integers as arguments, and returns the maximum of the three. The main() function then tests this function appropriately.
Solution
Sure, here is a Python function that does what you asked for:
def max_of_three(a, b, c):
"""This function takes three integers as arguments, and returns the maximum of the three."""
return max(a, b, c)
def main():
"""This function tests the max_of_three function."""
print(max_of_three(1, 2, 3)) # Expected output: 3
print(max_of_three(10, 5, 8)) # Expected output: 10
print(max_of_three(7, 9, 4)) # Expected output: 9
if __name__ == "__main__":
main()
In this code, the max_of_three function uses the built-in max function to find the maximum of the three input numbers. The main function then tests max_of_three with different sets of numbers.
Similar Questions
Write a C program that takes an array of integers and its size as input and returns the maximum element in the array.Requirements:The function should be named findMax.The function should take two parameters: an integer array and its size.The function should return the maximum element in the array.
Write a function int max_of_four(int a, int b, int c, int d) which reads four arguments and returns the greatest of them.
Problem StatementEmily is a budding programmer who loves solving mathematical problems. One day, she comes across a challenge to find the largest of three numbers using a custom function. Determined to tackle the challenge, she decided to create a program. Can you help her write the code and solve the problem?Function Specifications: double findMax(double a, double b, double c)Input format :The input consists of three space-separated double values a, b, and c.Output format :The output prints a double value which is the largest number of the given three numbers, rounded off to two decimal places.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:-100.00 ≤ a, b, c ≤ 100.00Sample test cases :Input 1 :2.22 3.98 3.99Output 1 :3.99Input 2 :-99.99 -10.78 -78.56Output 2 :-10.78Input 3 :-54.27 2.54 -23.58Output 3 :2.54
Given 3 integers A, B, and C such that A < B < CFind the value of max(A, B, C) - min(A, B, C)Here max(A, B, C) denotes the maximum value among A, B, C while min(A, B, C) denotes the minimum value among A, B, C.Input FormatThe first line of input will contain a single integer T, denoting the number of test cases.Each test case consists of 3 integers A, B, C.41 3 105 6 73 8 92 5 6Constraints1 <= T <= 101 <= A, B, C <= 10Output Format9264Sample Input 041 3 105 6 73 8 92 5 6Sample Output 09264Explanation 0Test case 1: Here, max(1,3,10)=10 and min(1, 3, 10) = 1. Thus, the difference is 9Sample Input 132 5 102 6 93 4 9Sample Output 1876
write a c program Find the largest number among the three numbers.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.