Comments

Monday, October 8, 2012

Array address using Pointers

Posted by at 2:18 PM Read our previous post


Intililize an integer array of 5 element .display values of all element
along with their addresses using pointer?



Source code


#include <iostream>
using namespace std;
void main()
{
       int Array[] = {1,2,3,4,5};
       int * ptr = Array; // Taking the address of first element in pointer;
       for(int loop = 0; loop < 5; loop ++)
       {
              cout << "Address of element no # " <<loop + 1 << ptr << "--------------" << " Value Is: "<< *ptr << endl;
              ptr ++;
       }
}


Output




 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template