Sunday, June 1, 2014

C++ Simple pointer program to print address and value

#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
     int a= 5;
 /* actual variable declaration */
 int *ptr;
 /* pointer variable declaration */
  ptr = &a;
   /* store address of a in pointer variable*/
   cout<<"Address of variable a="<< &a;
    cout<<"\nAddress stored in variable ptr="<<ptr;
     cout<<"\nValue of *ptr variable="<<*ptr;
     getch();
     return 0;
      }


No comments:

Post a Comment