← Back to Functions
Question 416
Function Pointer to Apply Operation
Function Pointer to Apply Operation
Write a functionint applyOp(int a, int b, int (*op)(int, int))that calls the function pointed to byopwithaandband returns the result. A functionint subtract(int a, int b)returninga - bis provided. Inmain, callapplyOp(10, 4, subtract)and print the result (see Expected Output). The third parameter is a pointer to a function that takes twoints and returns anint.
Expected Output:
6= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Functions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.