Back to C++ Notes
Topic #79

Pass Arrays


Pass Arrays as Function Parameters

You can also pass arrays to a function:

Example

void myFunction(int myNumbers[5]) {
  for (int i = 0; i < 5; i++) {

cout << myNumbers[i] << "\n";
  }
}

int main() {
  int
myNumbers[5] = {10, 20, 30, 40, 50};
  myFunction(myNumbers);
  return 0;
}

Note: Example Explained The function (myFunction) takes an array as its parameter (int myNumbers[5]), and loops through the array elements with the for loop. When the function is called inside main(), we pass along the myNumbers array, which outputs the array elements. Note that when you call the function, you only need to use the name of the array when passing it as an argument myFunction(myNumbers). However, the full declaration of the array is needed in the function parameter (int myNumbers[5]).

Want to go beyond the notes?

Join Coding Now Tech Institute's C++ course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Pass Arrays – FAQs

Quick answers about learning Pass Arrays in C++.

This free note from Coding Now Tech Institute explains Pass Arrays in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on Coding Now Tech Institute, including Pass Arrays, is 100% free with no signup required.
With focused practice, most students grasp Pass Arrays in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now