Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Functions and Array ArgumentsFunctions and Array Arguments ExamExam.

Similar presentations


Presentation on theme: "March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Functions and Array ArgumentsFunctions and Array Arguments ExamExam."— Presentation transcript:

1 March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Functions and Array ArgumentsFunctions and Array Arguments ExamExam Lab 12Lab 12

2 March 2005 2R. Smith - University of St Thomas - Minnesota Arrays in RAM Just a row of variablesJust a row of variables Pick out a variable using the “index”Pick out a variable using the “index” NO built-in information about sizeNO built-in information about size Two ways to indicate an array’s sizeTwo ways to indicate an array’s size –Separate integer(s) containing its size –A ‘sentinel value’

3 March 2005 3R. Smith - University of St Thomas - Minnesota How do we pass arrays? What does the function get when we pass an array?What does the function get when we pass an array? How do we signal the size of an array?How do we signal the size of an array? –How do we deal with ‘variable length’ arrays? –How do we mark the end of an array of chars (a string)? –How do indicate the number of elements in other arrays?

4 March 2005 4R. Smith - University of St Thomas - Minnesota How do we pass arrays? The function gets the array’s location in RAMThe function gets the array’s location in RAM The array must indicate its end somehowThe array must indicate its end somehow –Option: provide second parameter with the array size –Option: put a ‘sentinel’ at the end of the array, like in strings

5 March 2005 5R. Smith - University of St Thomas - Minnesota Lab 12 Four functions: min, max, sum, avgFour functions: min, max, sum, avg –Input: array info –Output: result of that operation –NO Text/Display Input or Output in these functions! –Do printf() back in the main() section. Run functions on 2 arrays of different sizesRun functions on 2 arrays of different sizes First 3 each have a loopFirst 3 each have a loop Fourth (avg) can call ‘sum’Fourth (avg) can call ‘sum’ Why keep printf() separateWhy keep printf() separate –Technical – there are times I/O is troublesome

6 March 2005 6R. Smith - University of St Thomas - Minnesota Exam 140 points140 points -14 – cutoff between A and B-14 – cutoff between A and B -28 – cutoff between B and C... etc.-28 – cutoff between B and C... etc.

7 March 2005 7R. Smith - University of St Thomas - Minnesota Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by- sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.


Download ppt "March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Functions and Array ArgumentsFunctions and Array Arguments ExamExam."

Similar presentations


Ads by Google