โ 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: 6 The third parameter is a pointer to a function that takes twoints and returns anint.
Expected Output:
6
Topics:
Functions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.