01969_PPT_ch06

# 01969_PPT_ch06 - Programming Logic and Design Fifth Edition...

This preview shows pages 1–13. Sign up to view the full content.

Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays

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

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 2 Objectives Understand arrays and how they occupy computer memory Manipulate an array to replace nested decisions Use a named constant to refer to an array’s size Declare and initialize an array Understand the difference between variable and constant arrays
Programming Logic and Design, Fifth Edition, Comprehensive 3 Objectives (continued) Search an array for an exact match Use parallel arrays Search an array for a range match Learn about remaining within array bounds Use a for loop to process arrays

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

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 4 Understanding Arrays and How They Occupy Computer Memory Array : Series or list of variables in computer memory All variables share the same name Each variable has a different subscript Subscript (or index ): Position number of an item in an array Subscripts are always a sequence of integers
Programming Logic and Design, Fifth Edition, Comprehensive 5 How Arrays Occupy Computer Memory Each item has same name and same data type Element : an item in the array Array elements are contiguous in memory Size of the array : number of elements it will hold

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

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 6 How Arrays Occupy Computer Memory (continued) Figure 6-1 Appearance of a three-element array and a single variable in computer memory
Programming Logic and Design, Fifth Edition, Comprehensive 7 How Arrays Occupy Computer Memory (continued) All elements have same group name Individual elements have unique subscript Subscript indicates distance from first element Subscripts are a sequence of integers Subscripts placed in parentheses or brackets following group name Syntax depends on programming language

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

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 8 Manipulating an Array to Replace Nested Decisions Example: Human Resources Department Dependents report List employees who have claimed 0 through 5 dependents Assume no employee has more than 5 dependents Application produces counts for dependent categories Uses series of decisions Application does not scale up to more dependents
Programming Logic and Design, Fifth Edition, Comprehensive 9 Figure 6-3 Flowchart of decision-making process using a series of decisions – the hard way

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

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 10 Figure 6-3 Pseudocode of decision-making process using a series of decisions – the hard way (continued)
Programming Logic and Design, Fifth Edition, Comprehensive 11 Manipulating an Array to Replace Nested Decisions (continued) Array reduces number of statements needed Six dependent count accumulators redefined as single array Variable as a subscript to the array Array subscript variable must be: Numeric with no decimal places Initialized to 0 Incremented by 1 each time the logic passes through the loop

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

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 12 Figure 6-4 Flowchart and pseudocode of decision-making process – but still a hard way
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern