Lecture25-LIN-10302019-ArrayII.pdf - Computing I COMP.1010 Fall 2019 Lecture 25 Array II(using array as function arguments University of By Sirong Lin

Lecture25-LIN-10302019-ArrayII.pdf - Computing I COMP.1010...

This preview shows page 1 - 10 out of 25 pages.

By: Sirong Lin, PhD Computing I University of Massachusetts Lowell COMP.1010, Fall 2019 Lecture 25: Array II (using array as function arguments)
Image of page 1
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Announcement Turn in Program 2 Design & Review 2
Image of page 2
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Upcoming Due Dates 3 Due Date Daily 18 10-30-2019 (W), 9:00pm Program 2 10-30-2019 (W), 9:00pm Week 9 Reading MWF, 9:00am Daily 19 11-01-2019 (F), 9:00pm Daily 20 11-04-2019 (M), 9:00pm Week 9 Practice Sun, 9:00pm
Image of page 3
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Outline Array II array and its elements as function arguments array and pointer 4
Image of page 4
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Array Concept an Array in C : uses two or more adjacent (contiguous) memory cells to store a collection of data items of the same type under a single name 5
Image of page 5
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Array (II) array element as function arguments array as function arguments array and pointer 6
Image of page 6
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Array Elements as Function Arguments — Pass by value Example Write a function, e.g., printElement , to display one array element with 5 columns 7 void printElement(int oneEle) { printf("%5d", oneEle); }
Image of page 7
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Array Elements as Function Arguments — Pass by value (Cont’d) #include <stdio.h> #define ARRAY_SIZE 5 void printElement(int oneEle); int main(int argc, char * argv[]) { int arr[ARRAY_SIZE] = {56, 23, 34, 12}; for (int i = 0; i < ARRAY_SIZE; ++i) { printElement(arr[i]); } return 0; } void printElement(int oneEle) { printf("%d\n", oneEle); } 8
Image of page 8
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin
Image of page 9
Image of page 10

You've reached the end of your free preview.

Want to read all 25 pages?

  • Fall '15

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

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors