---
title: "How to implement array in C++ plus plus  using function."  
description: "How to implement array in C++ plus plus  using function."  
author: "Abhishek Srivasatava"  
published: 2016-10-28  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/23091/how-to-implement-array-in-c-plus-plus-plus-plus-using-function  
category: "visual c++"  
tags: ["visual c++"]  
reading_time: 2 minutes  

---

# How to implement array in C++ plus plus  using function.

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>
using namespace 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.*/}}
```

## Answers

### Answer by Abhishek Srivasatava

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>
using namespace 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.*/}}
```


---

Original Source: https://www.mindstick.com/interview/23091/how-to-implement-array-in-c-plus-plus-plus-plus-using-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
