#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) { callback = sensorCallback; callback(value); } if (nullptr == callback) { cout << "NO CALLBACK" << endl; } // Write nullptr check and callback invocation here callback = nullptr; return 0; }
Test Cases
Test Results
Input
0 10
Expected Output
NO CALLBACK