{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

arrayfunction - Programming Passing Arrays to Functions...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Passing Arrays to Functions Programming
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
g. Fundamentals I: Passing Arrays to Function / Slide 2 Passing Arrays as Parameters Arrays are always passed by reference. The “[ ]” in the formal parameter specification indicates that the variable is an array. It is a good practice to pass the dimension of the array as another parameter. If the function must not change any element of the array then const should be used in the formal parameter specification of that array.
Image of page 2
g. Fundamentals I: Passing Arrays to Function / Slide 3 Smallest Value Problem Find the smallest value in a list of integers Input A list of integers and a value indicating the number of integers Output Smallest value in the list Note List remains unchanged after finding the smallest value!
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
g. Fundamentals I: Passing Arrays to Function / Slide 4 Preliminary Design Realizations When looking for value with distinguishing characteristics, need a way of remembering best candidate found so far Best written as a function - likely to be used often Design Search array looking for smallest value Use a loop to consider each element in turn If current element is smallest so far, then update smallest value so far candidate When done examining all of the elements, the smallest value seen so far is the smallest value
Image of page 4
g. Fundamentals I: Passing Arrays to Function / Slide 5 Necessary Information Information to be maintained
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern