Wednesday 2 July 2014

C++ program to print address and value of a variable using pointer


Here is a C++ program to print address and value of a variable using pointer


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    int n=10,*p;
    p=&n;
    cout<<"Address of variable in Hexadecimal "<<p<<endl;
    cout<<"Address of variable in Decimal "<<int(p)<<endl;
    cout<<"Its value "<<*p;
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment