You are writing a utility function that adds two values — but the values can be either:
You will be given void* pointing to the first and second value and a char type specifier: 'i' for int, 'f' for float.
'i'
'f'
Your task is to:
Use proper void* casting and dereferencing logic
Example-1
Input: type = i, a = 10, b = 20 Output: 30
Example-2
Input: type = f, a = 3.5, b = 2.5 Output: 6.0
Example-3
Input: type = i, a = -5, b = 7 Output: 2
Test Cases
Test Results
Input
i 10 20
Expected Output
30