25. Dynamic Integer Allocation

Back To All Submissions
Previous Submission
Next Submission
#include <iostream>
using namespace std;

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

    int* p = new int(x);  // Allocates int, initializes to x
    cout << (*p);
    delete p;              // Destroys and frees

    return 0;
}

Solving Approach

 

 

 

 

 

Was this helpful?
Upvote
Downvote