how to create an array with a variable in it c 2b 2b

Solutions on MaxInterview for how to create an array with a variable in it c 2b 2b by the best coders in the world

showing results for - "how to create an array with a variable in it c 2b 2b"
Lilli
29 Jun 2017
1// arrays as parameters
2#include <iostream>
3using namespace std;
4
5void printarray (int arg[], int length) {
6  for (int n=0; n<length; ++n)
7    cout << arg[n] << ' ';
8  cout << '\n';
9}
10
11int main ()
12{
13  int firstarray[] = {5, 10, 15};
14  int secondarray[] = {2, 4, 6, 8, 10};
15  printarray (firstarray,3);
16  printarray (secondarray,5);
17}