Write a program that defines a variable of type int called x, automatic storage duration, and a variable of type int* which points to an object with dynamic storage duration.
Both variables are in the same scope:
You can use the following code structure.
#include <iostream> int main() { //your code here }
#include <iostream> int main() { int x = 123; // automatic storage duration std::cout << "The value with an automatic storage duration is: " << x << '\n'; int* p = new int{ x }; // allocate memory and copy the value from x to it std::cout << "The value with a dynamic storage duration is: " << *p << '\n'; delete p; } // end of scope here