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:
- Contains 2 functions main() and reorder().
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started