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( );
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|