For the array implementation using function there is no need of any return type of function because address will be pass through the function. Any changes made in the function will directly reflect the main program.
#include <iostream>
usingnamespace std;
void stored(int *x, int n);
void printed(int *y,int z);
int main()
{
int num[10];
int max = 5;
stored (num,max);
printed(num,max);
}
void stored(int *x, int n)
{
int i;
for(i=0;i<n;i++)
{
cout <<"Enter the element "<<i<<endl;
cint>>x[i];
}
}
void printed(int *x, int n)
{
int i;
for(i=0;i<n;i++)
{
cout <<"Element :"<<x[i]<<endl;
*/cout << "*(x + " << i <<") : ";
cout << *(x + i) << endl; // We can also use this statement to print the output.
*/
}
}
Liked By
Write Answer
How to implement array in C++ plus plus using function.
Join MindStick Community
You have need login or register for voting of answers or question.
Abhishek Srivasatava
28-Oct-2016For the array implementation using function there is no need of any return type of function because address will be pass through the function. Any changes made in the function will directly reflect the main program.