Dynamic Integer Allocation

#include <iostream>
using namespace std;

int main() {
    int x;
    cin >> x;

    // Write your dynamic allocation code here
    int* p = new int;
    *p = x;
     cout << *p;         // print stored value

    delete p;           // free allocated memory
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

42

Expected Output

42