#include <iostream>
using namespace std;
int main() {
int x;
cin >> x;
int* p = new int; // dynamically allocate an integer
*p = x; // store input value
cout << *p; // print stored value
delete p; // free allocated memory
return 0;
}
Explanation & Logic Summary:
new int dynamically allocates memory on the heap.*p retrieves the stored value.delete p frees the allocated memory to prevent leaks.Firmware Relevance & Real-World Context:
new / delete is essential for:Input
42
Expected Output
42