Wednesday, 2 July 2014

C++ program to pass array to a function using pointer


Here is a C++ program to pass array to a function using pointer


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

Any questions regarding to program please write in comments.

No comments:

Post a Comment