In embedded firmware, optional callback functions are often used to handle events such as sensor data processing.
This problem focuses on safe callback invocation using nullptr.
You are given an input that specifies whether a callback is registered and a sensor value.
Your task is to safely invoke the callback only if it is registered.
Input Format:
flag value
flag (integer)0 → No callback is registered1 → Callback is registeredvalue (integer)Both values are space-separated and provided on a single line.
Output Format:
flag is 0, print:NO CALLBACK flag is 1, invoke the callback and print:DATA <value>
The output must match exactly, with no extra spaces or text.
Example 1
Input:
0 10
Output:
NO CALLBACK
Example 2
Input:
1 25
Output:
DATA 25
Constraints:
nullptr to represent the absence of a callbackvalue fits within a 32-bit signed integer
Input
0 10
Expected Output
NO CALLBACK