Explore BrainMass
Share

# C++ populating one and two dimensional arrays

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Define two pointers that hold two values of type int. Add these two pointers of type "int" and print the result on the screen.

Define a one dimensional array consisting of five cells, and populate the cells with values 0-5 and then print the result of the one dimensional array on the screen.

Define a two dimensional array of 6x6 cells. Its cells are populated with the value of one of the pointer times the value of one of the "FOR LOOP" variables, for example "i**pA". Print the result of the two dimensional array on the screen.

Write only one C++ code consisting of the above requirements. Output of your code should look like below:

The total of A and B is:6

****************************************

Content of one dimensional array is: 0

Content of one dimensional array is: 1

Content of one dimensional array is: 2

Content of one dimensional array is: 3

Content of one dimensional array is: 4

Content of one dimensional array is: 5

****************************************

Cell [0][0]=0

Cell [0][1]=4

Cell [0][2]=8

Cell [0][3]=12

Cell [0][4]=16

Cell [0][5]=20

Cell [1][0]=0

Cell [1][1]=4

Cell [1][2]=8

Cell [1][3]=12

Cell [1][4]=16

Cell [1][5]=20

Cell [2][0]=0

Cell [2][1]=4

Cell [2][2]=8

Cell [2][3]=12

Cell [2][4]=16

Cell [2][5]=20

Cell [3][0]=0

Cell [3][1]=4

Cell [3][2]=8

Cell [3][3]=12

Cell [3][4]=16

Cell [3][5]=20

Cell [4][0]=0

Cell [4][1]=4

Cell [4][2]=8

Cell [4][3]=12

Cell [4][4]=16

Cell [4][5]=20

Cell [5][0]=0

Cell [5][1]=4

Cell [5][2]=8

Cell [5][3]=12

Cell [5][4]=16

Cell [5][5]=20

Press any key to continue . . .

https://brainmass.com/computer-science/cpp/c-populating-one-and-two-dimensional-arrays-576446

#### Solution Preview

Attached source code (576446.cpp) is reasonably commented to help you understand what is being done there. It uses different values of A and B than the example output in your posting, so you will need to edit the source code appropriately to match its output with your example output.

There is small flaw in your ...

#### Solution Summary

There is small flaw in posting. It is asking to define a one dimensional array consisting of five cells, and populate its cells with values of 0-5 (0-5 are six values: 0,1,2,3,4,5). Response defines a one dimensional array consisting of six cells, but guides with alternatives in case you want to work with an array of five cells.

\$2.19