Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++) 1.What is the size of an Array? Give an example. 2.What is wrong with the following? Explain. Also give the corrected version. int Test_Array[8];

(C++)

1.What is the size of an Array? Give an example.

2.What is wrong with the following? Explain. Also give the corrected version.

int Test_Array[8];

cout

3.What are global and local array elements initialized to? Give examples.

4.What happens with the following piece of code? Why? Explain in detail.

int tests[5] = {79,82,91,77,84};

for (int count = 0; count

{

cout

}

5.What is range-based for loop? Give an example.

6.Give an example of how you would initialize a two dimensional array.

7.Read page 426. Visualize a multi dimensional Array. Give an example where you would use a 4 dimensional array.

(PAGE 426)

7.10 Arrays with Three or More Dimensions

CONCEPT: C++ does not limit the number of dimensions that an array may have. It is possible to create arrays with multiple dimensions, to model data that occur in multiple sets.

C++ allows you to create arrays with virtually any number of dimensions. Here is an example of a three-dimensional array definition:

double seats[3][5][8]; 

This array can be thought of as three sets of five rows, with each row containing eight elements. The array might be used to store the prices of seats in an auditorium, where there are eight seats in a row, five rows in a section, and a total of three sections.

Figure 7-18 illustrates the concept of a three-dimensional array as pages of two-dimensional arrays.

image text in transcribed

Figure 7-18

Arrays with more than three dimensions are difficult to visualize, but can be useful in some programming problems. For example, in a factory warehouse where cases of widgets are stacked on pallets, an array with four dimensions could be used to store a part number for each widget. The four subscripts of each element could represent the pallet number, case number, row number, and column number of each widget. Similarly, an array with five dimensions could be used if there were multiple warehouses.

image text in transcribed NOTE:

When writing functions that accept multi-dimensional arrays as arguments, all but the first dimension must be explicitly stated in the parameter list.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

=+ how might this lead to faster growth in productivity?

Answered: 1 week ago