#include <iostream> using namespace std; // Callback function that prints sensor data void sensorCallback(int v) { cout << "DATA " << v; } int main() { int flag, value; cin >> flag >> value; void (*callback)(int) = nullptr; // optional callback pointer if (flag == 1) { // Assign callback pointer here. callback = sensorCallback; } // Write nullptr check and callback invocation here if (callback == nullptr) { cout << "NO CALLBACK"; } else { callback(value); } return 0; }
Test Cases
Test Results
Input
0 10
Expected Output
NO CALLBACK