#include <iostream> using namespace std; int main() { int flag; cin >> flag; int* sensorPtr = nullptr; if (flag == 1) { sensorPtr = new int; cin >> *sensorPtr; } if (sensorPtr == nullptr) { cout << "NO SENSOR"; } else { cout << *sensorPtr; } delete sensorPtr; return 0; }
Explanation & Logic Summary:
sensorPtr
nullptr
delete
Firmware Relevance & Real-World Context:
Test Cases
Test Results
Input
0
Expected Output
NO SENSOR