Answers for "how to create an array with a variable in it c++"

C++
0

how to create an array with a variable in it c++

// arrays as parameters
#include <iostream>
using namespace std;

void printarray (int arg[], int length) {
  for (int n=0; n<length; ++n)
    cout << arg[n] << ' ';
  cout << '\n';
}

int main ()
{
  int firstarray[] = {5, 10, 15};
  int secondarray[] = {2, 4, 6, 8, 10};
  printarray (firstarray,3);
  printarray (secondarray,5);
}
Posted by: Guest on April-27-2021

Code answers related to "how to create an array with a variable in it c++"

Browse Popular Code Answers by Language