Mega Code Archive

 
Categories / C++ Tutorial / Function
 

Pass int array to a function

#include <iostream>  using namespace std;    void display(int num[10]);    int main()  {    int t[10], i;      for(i=0; i < 10; ++i) t[i]=i;      display(t); // pass array t to a function      return 0;  }    void display(int num[10])  {    int i;      for(i=0; i < 10; i++) cout << num[i] << ' ';  } 0 1 2 3 4 5 6 7 8 9