CH11 - An Introduction to Programming with C+, Fifth...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
An Introduction to Programming with C++, Fifth Edition 11 - 1 Chapter 11 Arrays At a Glance Instructor’s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Topics Classroom Activities/Additional Projects Key Terms
Background image of page 1

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

View Full DocumentRight Arrow Icon
An Introduction to Programming with C++, Fifth Edition 11 - 2 Lecture Notes Chapter Overview This chapter covers the basic concepts involved with arrays. Implementing one-dimensional and two-dimensional arrays in C++ is covered, as well as various algorithms using arrays. Some of these include displaying the contents of an array, searching an array, finding the highest entry in an array, and computing the average of an array’s elements. The concept of parallel arrays will also be covered. Chapter Objectives After completing the chapter, the student will be able to: Declare and initialize a one-dimensional array Manipulate a one-dimensional array Explain the bubble sort algorithm Pass a one-dimensional array to a function Use parallel one-dimensional arrays Declare and initialize a two-dimensional array Enter data into a two-dimensional array Search a two-dimensional array Utilize a one-dimensional array in a .NET C++ program Instructor Notes Using Arrays All of the variables you have used in the previous chapters have been simple variables. A simple variable, also called a scalar variable, is one that is unrelated to any other variable in memory. In many programs however, you may need to reserve a block of memory locations. This block of memory locations is referred to as an array. An array is a group of variables that have the same name and data type, and are related in some way. The most commonly used arrays in programs are one-dimensional and two-dimensional arrays. A one-dimensional array is simply a column of variables. A two-dimensional array, on the other hand, resembles a table in that it has rows and columns.
Background image of page 2
An Introduction to Programming with C++, Fifth Edition 11 - 3 Programmers use arrays to temporarily store related data in the internal memory of the computer. By doing so, a programmer can increase the efficiency of a program because data stored in an array (which is inside the computer in memory) can be both written and read much faster than data stored in a data file on a disk. Additionally, after the data is entered into an array, which typically is done at the beginning of the program, the program can use the data as many times as desired. One-Dimensional Arrays One way to understand an array is to visualize it as a column of variables, where each variable is considered to be an element of the array. Each array element is assigned a unique number, called a subscript (sometimes called the index). The first element in a one-dimensional array in C++ is assigned a subscript value of zero (0). Because the first element is assigned a subscript value of zero (0), the last subscript value for an array is one less than the number of elements in the array. For example, an array with ten (10) elements will be referenced using the subscripts zero (0)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/11/2010 for the course CS 343 taught by Professor Katzman during the Spring '09 term at ITT Tech Tucson.

Page1 / 8

CH11 - An Introduction to Programming with C+, Fifth...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online