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.
*/
}
}
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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.