#include <iostream> using namespace std; int main() { int flag; cin >> flag; int* sensorPtr = nullptr; // optional sensor pointer if (flag == 1) { sensorPtr = new int; cin >> *sensorPtr; } // Write your nullptr check and output logic here sensorPtr ? printf("%d",*sensorPtr) : printf("NO SENSOR"); delete sensorPtr; // safe even when sensorPtr == nullptr return 0; }
Test Cases
Test Results
Input
0
Expected Output
NO SENSOR