Code Competitions

Coding competition

Tuesday, 28 May 2013

Program to show the use of array of pointer

#include<iostream.h>
#include<conio.h>
void main()
{
    int *a,*p[50],n,i;
    clrscr();
    cout<<"enter the size of array ";
    cin>>n;
    cout<<" enter the elements of array";
    for(i=0;i<n;i++)
    {
        cout<<"\na["<<i<<"]= ";
        cin>>*(a+i);
        p[i]=(a+i);
    }
    clrscr();
    cout<<" entered elements are :";
    for(i=0;i<n;i++)
    {
        cout<<"\naddress "<<p[i];
        cout<<" "<<(a++);
    }
    cout<<"\n\n";
    for(i=0;i<n;i++)
    {
        cout<<"\naddress "<<p[i]<<"\n value is "<<*(*(p+i));
    }
    getch();
}
OUTPUT:

No comments:

Post a Comment