C++ Memory Address

#include <iostream>

int main() {
    int x = 42;  // Step 1: Declare an integer variable 'x' and assign the value 42.
    int* ptr = &x;  // Step 2: Declare a pointer variable 'ptr' to an integer and assign the address of 'x' to it.

    std::cout << "Value of x: " << x << std::endl;  // Step 3: Print the value of 'x'.
    std::cout << "Address of x: " << &x << std::endl;  // Step 4: Print the address of 'x'.
    std::cout << "Value at the address pointed by ptr: " << *ptr << std::endl;  // Step 5: Print the value at the address pointed by 'ptr'.
    std::cout << "Address of ptr: " << &ptr << std::endl;  // Step 6: Print the address of 'ptr'.

    return 0;
}