free a pointer c++

#include <iostream>

int main() {
    // Step 1: Declare a pointer
    int* ptr = new int;

    // Step 2: Allocate memory using 'new' operator
    // (This step is combined with Step 1 in the declaration)

    // Step 3: Assign a value to the allocated memory
    *ptr = 42;

    // Step 4: Deallocate the memory using 'delete' operator
    delete ptr;

    return 0;
}