Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. C reate a one dimensional array, Ages, which will hold 4 ages. Each age is an int. b. Write a for loop and print,

1. Create a one dimensional array, Ages, which will hold 4 ages. Each age is an int.

b. Write a for loop and print, in reverse order the 4 values stored in memory assuming that the ages in the previous question have already been entered with a space between each value. Use subscript notation.

short cnt;

c. Do the same as above, but use pointer notation.

2. Create, but do not initialize with data, one array for each of the following situations. Use an appropriate data type and name for each array:

a. holding the height of 10 students - 1 dimension - use most efficient storage size

b. holding payments per year arranged like this table to be printed in a book

(Year and 1,2,3,4,5 are NOT part of the array. Neither are 6.5%, 6.75%, 7.0%)

Year

1 2 3 4 5

6.5% 123.23 104.32 99.23 80.75 67.45

6.75% 131.24 111.54 103.23 90.55 78.95

7.0% 141.54 120.54 107.43 98.67 88.98

There will be 75 tables like this for different amounts in the book.

Create the array to hold these 75 tables.

3. Using the array name and proper subscripts, print the 120.54 from the above array considering it is the 62nd table in the array of tables.

4. Convert to pointer notation using the same variable:

data[9]

ddata[2][5]

5. Use cout to print the address at which the following array is stored in the computer memory.

short YourData[12];

a. Print the address of the first element of the array

b. Print the address of the fifth element of the array

6. a. Given the following array and variables, print it so that all the items from 1 column are printed before any items on the second column, etc. Use for loop constructs, NOT while loop. Use subscript notation.

float TestData[10][20];

int row, col;

b. Dos the same as above using pointer notation.

7. Given the following, write the code to have C++ calculate:

long Arr [100];

a. Using the array name, Arr, calculate NUMBER OF BYTES IN ONE ELEMENT:

b. Calculate the NUMBER OF BYTES IN ONE ELEMENT using the data type

(problematic for future code maintenance).

c. Calculate the total number of bytes in the entire array.

d. Calculate the number of elements in the array.

Anything relating to reference variables or arrays will be so described. Assume any others are by value

8. Write the header line for the following functions - each function is named F1

A function returning a long and receiving as data parameters a short, an array of float and an array of double.

b. A function returning a reference to an int and receiving a 2 dimensional array of double with 23 columns.

c. Returning an int and receiving 3 int reference variables.

9. Write the following functions in full, including header line and body. Call each F1.

a. Receives 4 arguments, two arrays of short and two int's, one for each array, containing the count of array elements in that array. The function computes one grand total for both arrays. It then returns the grand total.

b. Receives an array of long. Returns the 2nd value stored in the array.

c. Write a function to receive a 2 dimensional array of long double with 10 columns. Also you will receive a short value representing the number of rows. The function totals all of the amounts in the array. The total of the values is returned as a long double.

d. . This function, F1, receives a pointer to an int array and a pointer to a double as arguments. It then calls the function called F2, which has the following prototype:

void F2( int *arr, double num );

F1 is going to call F2 and send the array and the double value as arguments, receiving nothing back.

Write the entire function F1 which calls F2 as its only operation.

e. Change this function to reference variables:

int * fun1( float *a, int *b, float d)

{

*a = *b * d;

return a;

}

Rewrite the entire function below:

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

More Books

Students also viewed these Databases questions

Question

4 How can you create a better online image for yourself?

Answered: 1 week ago