🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
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 CodingNow 2.0'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 CodingNow 2.0 explains Pass Arrays in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on CodingNow 2.0, 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 CodingNow 2.0'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 CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now