Wednesday, 2 July 2014

C++ program to access array elements using pointer


Here is a C++ program to access array elements using pointer


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    int x[5]={10,20,30,40,50},*p;
    p=&x[0];
    cout<<"Array elements : ";
    for(int i=0;i<5;i++)
    {
        cout<<*p<<" ";
        p++;
    }
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment