C++ Programming Blog

 
 
 

Image

 /**************************************************************************
  **************************************************************************

  A C++ Program to illustrate supplying of values to pointer variables.

  **************************************************************************
  *************************************************************************/

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

 main()
    {
       clrscr();

       int i=10;
       int *j;

       j=&i;

       cout<<\"\\n ---------- Addresses of Variables --------- \\n\"<<endl;
       cout<<\"Address of i = \"<<&i<<endl;
       cout<<\"Address of j = \"<<&j<<endl;

       cout<<\"\\n ---------- Values of Variables -------- \\n\"<<endl;
       cout<<\"value of i = \"<<i<<endl;
       cout<<\"value of j = \"<<j<<endl;
       cout<<\"value of *&i = \"<<*&i<<endl;
       cout<<\"value of *j = \"<<*j<<endl;

       cout<<\"\\n *j = 5 \\n\"<<endl;
       *j=5;

       cout<<\"value of *j after modification = \"<<*j<<endl;

       getch();
       return 0;
    }

 
 
Didn't find what you were looking for? Find more on Program to illustrate supplying of values to pointer variables