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