Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
9th Edition
ISBN: 9780134520520
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
Question
Book Icon
Chapter 8.11, Problem 8.23CP
Program Plan Intro

Two-dimensional array:

A two dimensional array is also called as a multi-dimensional array; a multidimensional array is that all the identical arrays are put together into a single array.

  • This is useful for storing same type of multiple sets of data in same place.
  • The main advantage is that one-dimensional array can hold only one set of value whereas two-dimensional array can hold multiple sets of data in the form of rows and columns.
  • The structure of a multi-dimensional array is lookalike a table (that is combination of rows and columns); it contains same type of columns.
  • The array elements can be referred by the index numbers of the array; the index numbers for an “n x n” size array would be from “0, 0” to “n-1, n-1”.

For example, the index numbers of “3 x 3” array would be from “0, 0” to “2, 2” (that is (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), and (2, 2)).

Declaring two-dimensional array:

The following example illustrates the declaration of two dimensional array:

Example:

//Declaring multi-dimensional array

double testmarks[2][3];

The above statement is used to create a multidimensional array with “2” rows and “3” columns; the first subscript (that is square bracket) is used to refer the number of rows and the second subscript is used to refer the number of columns.

  • The data type “double” represents that the array will hold only “double” type of data.
  • The “testmarks” array can hold 6 elements (that is × 3 = 6 ).

Initialization of two dimensional arrays:

  • While initializing the values for two-dimensional array, it is need to enclose each initialization of row with set of braces.
  • The extra braces which encloses the row’s initialization list are optional,
    • This extra brace helps to separate each row and the user may sometimes leave out the initializers within a row instead of omitting the initializers for the rows that follow it.
  • The index numbers of “2 x 3” array would be from “0, 0” to “1, 2” .

Example:

//Initializing the multi-dimensional array

double testmarks[2][3] = {{8,5,2},{4,1,7}};

The above statement is used to create a multidimensional array with “2” rows and “3” columns and the values are assigned in testmarks[] array as,

testmarks[0][0] = 8;

testmarks[0][1] = 5;

testmarks[0][2] = 2;

testmarks[1][0] = 4;

testmarks[1][1] = 1;

testmarks[1][2] = 7;

Blurred answer
Students have asked these similar questions
What data type is needed to store 09:05? Select one: a. Double b. Time c. Single d. Date   It determines the position of each array element. Select one: a. location b. none of the choices c. name d. index
Create a one dimensional array that contains the following: "Cath, Donna, Anna, Bob, Mae". Write a code that will check all elements of the array. If the name "Anna" exists in the array, display "Record Found!" otherwise, display "Record not Found".
Please answer according to the image attached. No need for explanation! What is the name of the variable that will store the value that you are searching? What is the name of the array that stores the values? What is the data type of found? (True or False) The program makes use of a dynamic array. (True or False) The program will compare the search item to each of the element in the array. (True or False) The worst case scenario in a sequential search is when the item you are looking for is not found in the list.  What will be the value of found when a search is successful? What variable represents the output of the output of the function? What is the output if a search is unsuccessful? What is the data type that will be returned by the function?

Chapter 8 Solutions

Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)

Ch. 8.7 - Given the following array definition: int values...Ch. 8.7 - Prob. 8.12CPCh. 8.7 - Prob. 8.13CPCh. 8.7 - What is the output of the following code? const...Ch. 8.9 - Write a typedef statement that makes the name...Ch. 8.9 - Prob. 8.16CPCh. 8.9 - What is the output of the following program...Ch. 8.9 - The following program segments, when completed,...Ch. 8.11 - Prob. 8.19CPCh. 8.11 - Prob. 8.20CPCh. 8.11 - Prob. 8.21CPCh. 8.11 - Prob. 8.22CPCh. 8.11 - Prob. 8.23CPCh. 8.11 - Fill in the empty table below so it shows the...Ch. 8.11 - Write a function called displayArray7. The...Ch. 8.11 - Prob. 8.26CPCh. 8.12 - Prob. 8.27CPCh. 8.12 - Write definition statements for the following...Ch. 8.12 - Define gators to be an empty vector of ints and...Ch. 8.13 - True or false: The default constructor is the only...Ch. 8.13 - True or false: All elements in an array of objects...Ch. 8.13 - What will the following program display on the...Ch. 8.13 - Complete the following program so that it defines...Ch. 8.13 - Add two constructors to the Product structure...Ch. 8.13 - Prob. 8.35CPCh. 8.13 - Prob. 8.36CPCh. 8.13 - Prob. 8.37CPCh. 8.13 - Write the definition for an array of five Product...Ch. 8.13 - Write a structure declaration called Measurement...Ch. 8.13 - Write a structure declaration called Destination ,...Ch. 8.13 - Define an array of 20 Destination structures (see...Ch. 8 - The ________ indicates the number of elements, or...Ch. 8 - The size declarator must be a(n) _______ with a...Ch. 8 - Prob. 3RQECh. 8 - Prob. 4RQECh. 8 - The number inside the brackets of an array...Ch. 8 - C++ has no array ________ checking, which means...Ch. 8 - Prob. 7RQECh. 8 - If a numeric array is partially initialized, the...Ch. 8 - If the size declarator of an array definition is...Ch. 8 - Prob. 10RQECh. 8 - Prob. 11RQECh. 8 - Prob. 12RQECh. 8 - Arrays are never passed to functions by _______...Ch. 8 - To pass an array to a function, pass the ________...Ch. 8 - A(n) ________ array is like several arrays of the...Ch. 8 - Its best to think of a two -dimensional array as...Ch. 8 - Prob. 17RQECh. 8 - Prob. 18RQECh. 8 - When a two -dimensional array is passed to a...Ch. 8 - When you pass the name of an array as an argument...Ch. 8 - Look at the following array definition. int values...Ch. 8 - Given the following array definition: int values...Ch. 8 - Prob. 23RQECh. 8 - Assume that array1 and array2 are both 25-element...Ch. 8 - Prob. 25RQECh. 8 - How do you establish a parallel relationship...Ch. 8 - Look at the following array definition. double...Ch. 8 - Prob. 28RQECh. 8 - Prob. 29RQECh. 8 - Prob. 30RQECh. 8 - Prob. 31RQECh. 8 - The following code totals the values in each of...Ch. 8 - Prob. 33RQECh. 8 - Prob. 34RQECh. 8 - In a program you need to store the identification...Ch. 8 - Prob. 36RQECh. 8 - Prob. 37RQECh. 8 - Prob. 38RQECh. 8 - Each of the following functions contains errors....Ch. 8 - Soft Skills Diagrams are an important means of...Ch. 8 - Perfect Scores 1. Write a modular program that...Ch. 8 - Larger Than n Create a program with a function...Ch. 8 - Roman Numeral Converter Write a program that...Ch. 8 - Chips and Salsa Write a program that lets a maker...Ch. 8 - Monkey Business A local zoo wants to keep track of...Ch. 8 - Rain or Shine An amateur meteorologist wants to...Ch. 8 - Lottery Write a program that simulates a lottery....Ch. 8 - Rainfall Statistics Write a modular program that...Ch. 8 - Lo Shu Magic Square The Lo Shu Magic Square is a...Ch. 8 - Baseball Champions This challenge uses two files...Ch. 8 - Chips and Salsa Version 2 Revise Programming...Ch. 8 - Stats Class and Rainfall Statistics Create a Stats...Ch. 8 - Stats Class and Track Statistics Write a client...Ch. 8 - Prob. 14PCCh. 8 - Drivers License Exam The State Department of Motor...Ch. 8 - Array of Payro11 Objects Design a PayRoll class...Ch. 8 - Drink Machine Simulator Create a class that...Ch. 8 - Bin Manager Class Design and write an object...Ch. 8 - Tic-Tac-Toe Game Write a modular program that...Ch. 8 - Theater Ticket Sales Create a TicketManager class...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning