Passing an Array to a Function by Declaring the Array in?the Function Header - C++ Data Type

C++ examples for Data Type:Array

Description

Passing an Array to a Function by Declaring the Array in?the Function Header

Demo Code

#include <iostream>

using namespace std;



void myfunction(int myarray[], int size)
{
  for (int i = 0; i<size; i++)
  {//from ww w . ja  va  2s  . co m
    cout << myarray[i] << endl;
  }
}

int main()
{
  int myArray[10];

  for (int i = 0; i<10; i++)
  {
    myArray[i] = i * 2;
  }

  myfunction(myArray, 10);

  return 0;
}

Result


Related Tutorials