Question: Using Visual Studio, write a C++ program that does the following: Contains 2 functions main() and reorder(). The main() function should: - Print your name

Using Visual Studio, write a C++ program that does the following:

  1. Contains 2 functions main() and reorder().
  2. The main() function should:

- Print your name

- Dynamically allocate memory for 3 integer variables named x, y and z (this should be 3 separate allocations, dont allocate an array)

- Generate 3 random numbers from 1-100 and store in the 3 integers. Use the system rand() function.

- Print the values of the 3 integers in order (x, y, z)

- Call function reorder(), passing pointers to the 3 integers

- After return from reorder(), print the values of the 3 integers in order (x, y, z)

3) The prototype for reorder() will be:

void reorder (int *n1, int *n2, int *n3);

4) Include the prototype for reorder() in your program.

5) The reorder() function should:

- sort the integers from lowest to highest, putting the smallest value in a, next to smallest in b and largest in c. This may involve swapping the values around.

*Note, this is all the reorder() function should do. Printing the values, etc. should be done in main().

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!