50. Event-Based Triggers Using Function Pointer Array

You are building a simple event handling system where different event codes (0 to 4) trigger different actions.

Each event type corresponds to a specific function:

Event CodeTrigger TypeFunction
0Button Presson_button()
1Timer Expireon_timer()
2UART Receivedon_uart()
3Power Onon_power()
4Error Detectedon_error()

You must:

  • Implement a function pointer array
  • Trigger the correct function based on the input event code
  • If the code is outside the 0–4 range, print "Unhandled Event"
     

Example-1

Input: 1
Output: Timer Expired


Example-2

Input: 3
Output: Power On


Example-3

Input: 5
Output: Unhandled Event


 

Loading...

Input

0

Expected Output

Button Pressed