In this post, we will write a C++ program to display the address of a variable.

C++ program to display address of a variable


C++ program to display address of a variable

#include<iostream>
#include<conio.h>

int main()
{
    system("cls");

    int a;
    int *p;

    a = 5;
    p = &a;

    std::cout<<"The value of a = "<<a<<std::endl;
    std::cout<<"The memory address of a = "<<p;

    getch();
    return 0;
}



Output

The value of a = 5
The memory address of a = 0xBf82fff4