Program to illustrates Accessing Array elements using pointers


#include<iostream.h>
#include<conio.h>
void main( )
{
        int A [ ] = { 11, 33, 55, 77, 99 } ;
     int *j ;
     j = &A[0] ;                     //assign address of  0th element
        for ( int i = 0; i <= 4; i++)
        {
            cout<<"\n Address =  "<< j<< "\t" ;
            cout<<" Element  = "<< *j ;
            j ++ ;       // increment pointer to point next location
    }
    getch( );
}

No comments:

Post a Comment