Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

https://pastebin.com/M6L68nh6 ********I have already completed activity #1, you

ID: 3585660 • Letter: H

Question

https://pastebin.com/M6L68nh6

********I have already completed activity #1, you can find the code below, can you help me with activity #2?********

Using C++

The main purpose of this lab is to create functions using call-by-value and call- by-reference parameters.

Activity #1

The first activity will be to write a function that sort an array of numbers (passed as a parameter) in ascending order. The input and output for the program are as follows:

Input/Output:

Enter 5 integers: 1 23 4 54 3

The array of integers sorted in ascending order is: 1 3 4 23 54

Include a function swapper(int& a, int& b) that can be used in your sort function. Save the source code in a file named assignment1.cpp.

Activity #2

Once you have completed the first activity, you should modify the program created in Activity #1 to take randomly generated input instead of command-line input. Save the source code in a file named assignment2.cpp.

Use the “time” command to detect how long it takes to sort 1000 numbers and 10,000 numbers. Include the time result as a comment in your program

Explanation / Answer

For activity 2:

To generate a random number: use the rand() function available in cstdlib library. You can use it in a for loop, and save the number generated in either an array or five different variables, just as you would have stored in activity1. E.g.:

int num1=rand();

or

for(int I=0; I<5;I++)

{

nums[i]=rand();

}

Regarding the time part of problem, its not clear if you have solved it or not, as it is related to activity1.

Just a hint to solve it: you will have to save the current time before calling sort method first time, use it to sort 1000 or 10000 numbers, and then after sorting is complete, check the current time again. The difference will be the total time taken to sort. You can use standard time functions available in c++ for time calculations.