Question: Please make it simple.. Program #1 (Id: 168876) Chapter 9, Programming Challenge #5 (p.545) The following function uses reference variables as parameters. Rewrite the function

Please make it simple..

Program #1 (Id: 168876)

Chapter 9, Programming Challenge #5 (p.545)

The following function uses reference variables as parameters. Rewrite the function so it uses pointers instead of reference variables, and then demonstrate the function in a complete program.

int doSomething(int &x, int &y) {

int temp = x;

x = y * 10;

y = temp * 10;

return x + y;

}

Note: Your program should ask the user for 2 integer values, and print 3 integer values back.

Sample Output:

Please Enter a value for x? 7

Please Enter a value for y? 8

The result of the function was: 150

x's current value is 80

y's current value is 70

Press any key to continue . . .

......................................................................................................

Program #2 (Id: 168987)

Chapter 9, Programming Challenge #10 (p.546)

Write a function that accepts an int array and the arrays size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer to the new array. Demonstrate the function in a complete program.

Notes:

Your program should ask the user for the size of the array to create, as well as each of the values for it.

Please display the array in a similar fashion (i.e. a comma separated list of values with square brackets on the ends)

You will need to have a function with the word reverse in the name, it should return a integer pointer, and have an integer pointer and int for parameters.

In the main function, you should have two integer pointers, one for the input and one for the reversed array returned by the function.

You should have 2 for loops in the main function, and one in the reversing function.

Sample Output:

Enter the size of the array: 4

Enter Value 1: 1

Enter Value 2: 2

Enter Value 3: 3

Enter Value 4: 4

The reversed array is: [4,3,2,1]

Press any key to continue . . .

.......................................................................................

Program #3 (Id: 169098)

Chapter 9, Programming Challenge #10 (p.546)

Write a function that accepts an int array and the arrays size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array and initialize the unused elements of the second array with 0. The function should return a pointer to the new array.

Notes:

The user should be asked for the size of the array, as well as the values for the first array created.

Please display the array in a similar fashion (i.e. a comma separated list of values with square brackets on the ends)

You will need to have a function with the word expand in the name, it should return a integer pointer, and have an integer pointer and int for parameters.

In the main function, you should have two integer pointers, one for the input and one for the expanded array returned by the function.

Sample Output:

Enter the size of the array: 6

Enter Value 1: 1

Enter Value 2: 2

Enter Value 3: 3

Enter Value 4: 4

Enter Value 5: 5

Enter Value 6: 6

The expanded size array is: [1,2,3,4,5,6,0,0,0,0,0,0]

Press any key to continue . . .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!