Answer the following questions regarding an array called table:
Output:
fractions[ 0 ] = 0.0
fractions[ 1 ] = 0.0
fractions[ 2 ] = 0.0
fractions[ 3 ] = 0.0
fractions[ 4 ] = 0.0
fractions[ 5 ] = 0.0
fractions[ 6 ] = 3.333
fractions[ 7 ] = 0.0
fractions[ 8 ] = 0.0
fractions[ 9 ] = 1.667
a) Declare the array to be an integer array and to have 3 rows and 3 columns. Assume that the constant variable arraySize has been defined to be 3.
b) How many elements does the array contain?
c) Use a for statement to initialize each element of the array to the sum of its subscripts. Assume that the integer variables i and j are declared as control variables.
d) Write a program segment to print the values of each element of array table in tabular format with 3 rows and 3 columns. Assume that the array was initialized with the declaration
int table[ arraySize ][ arraySize ] = { { 1, 8 }, { 2, 4, 6 }, { 5 } };
and the integer variables i and j are declared as control variables. Show the output.
a) ```
int table[ arraySize ][ arraySize ];
```
b) Nine.
c) ```
for ( i = 0; i < arraySize; i++ )
for ( j = 0; j < arraySize; j++ )
table[ i ][ j ] = i + j;
```
d) ```
cout << " [0] [1] [2]" << endl;
for ( int i = 0; i < arraySize; i++ ) {
cout << '[' << i << "] ";
for ( int j = 0; j < arraySize; j++ )
cout << setw( 3 ) << table[ i ][ j ] << " ";
cout << endl;
}
Output:
[0] [1] [2]
[0] 1 8 0
[1] 2 4 6
[2] 5 0 0
```
You might also like to view...
Define an iterator called position that will reference elements of a vector of string elements.
What will be an ideal response?
When installing from a CD, wait a few seconds for the _____ to begin.
A. Help program B. setup routine C. Reinstall program D. compression routine
Which function name is invalid?
A. Function-to-Calc-Price B. Function to CalcPrice C. Function_To_Calc?? D. They are all invalid
Match the following terms to their meanings:
I. Split form II. Nested subform III. Subform IV. Multi page form V. Linked form VI. Main form A. a related form that is not stored within the main form B. displays data in two views on a single form C. a form that contains a subform D. a form that is embedded within another subform E. displays the data from underlying table or query on more than one page F. a form that is embedded within another form