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

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

View Full Document Right Arrow Icon
Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
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
Image of page 5

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

View Full Document Right Arrow Icon
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
Image of page 6
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
Image of page 7

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

View Full Document Right Arrow Icon
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
Image of page 8
Programming Logic and Design, Fifth Edition, Comprehensive 9 Figure 6-3 Flowchart of decision-making process using a series of decisions – the hard way
Image of page 9

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

View Full Document Right Arrow Icon
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)
Image of page 10
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
Image of page 11

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

View Full Document Right Arrow Icon
Programming Logic and Design, Fifth Edition, Comprehensive 12 Figure 6-4 Flowchart and pseudocode of decision-making process – but still a hard way
Image of page 12
Image of page 13
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