151. Button Press Callback

 A button should trigger an action when pressed.
 We already have two callback functions defined:

void onPressA() { cout << "Button A pressed\n"; }
void onPressB() { cout << "Button B pressed\n"; }

Your task is to implement the function:

void simulatePress(void (*callback)())
  • It should call the function passed as the callback. 

In main():

  • Input is "A" or "B".
  • Based on input, the correct callback function is passed to simulatePress. 

Example:

Example 1
 Input:

A

Output:

Button A pressed

Example 2

Input:

B

Output:

Button B pressed

 

 

 

 

Loading...

Input

A

Expected Output

Button A pressed