Wednesday, 2 November 2016

12D. Prog-12 Write a Program to print the address and value at address by using the concept of array of pointers.

//12D. Prog-12 Write a Program to print the address and value at address by using the concept of
//array of pointers.

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

void main()
{
  clrscr();
  int *ptr[5];
  int a,b,c,d,e;
  ptr[0]=&a;
  ptr[1]=&b;
  ptr[2]=&c;
  ptr[3]=&d;
  ptr[4]=&e;
 
  for(int i=0;i<5;i++)
  {
    cout<<"\n Enter value for location "<<i+1<<" ";
    cin>>*ptr[i];
  }
   for(i=0;i<5;i++)
   {
     cout<<"\n value at location "<<i+1<<" ";
     cout<<" : "<<*ptr[i];
     cout<<"\n At address"<<ptr[i];
   }
   getch();
}

No comments:

Post a Comment