C++ Program to Print Address of Variables

In this program, we will learn how to print addresses of variables that you created in program.



Source Code
#include<iostream>
using namespace std;

int main()
{
    int a,b;
    a=5;
    b=10;
    cout<<"\n Value of a = " << a;
    cout<<"\n Address of a = " << &a;
    cout<<"\n Value of b = " << b;
    cout<<"\n Address of b = " << &b;
    return 0;
}
Output
 Value of a = 5
 Address of a = 0x23fe4c
 Value of b = 10
 Address of b = 0x23fe48