![]() |
VOOZH | about |
Given two Integers A and B, your task is to find the average of two numbers where the average is given by the formula:
average(A, B) = (A+B)/2
Examples:
Input: A=5, B=3
Output: 4
Explanation: Average(A,B) = (A+B)/2 = 8/2 =4Input: A=10, B=5
Output: 7.5
Explanation: Average(10, 5) = (10 + 5)/2 = 15/2 = 7.5
Approach: To solve the problem, follow the below idea:
We can find the average of two number by summing the number using the '+' operator and then divide the sum by 2 to get the final answer.
Step-by-step algorithm:
Below is the implementation of the algorithm:
Average of 10 and 5 = 7.5
Time Complexity: O(1)
Auxiliary Space: O(1)