1 answer

Description: Write a complete C++ program that will do the following: 1. Declare an array of...

Question:

Description: Write a complete C++ program that will do the following: 1. Declare an array of 30 elements 2. Set the array to

Description: Write a complete C++ program that will do the following: 1. Declare an array of 30 elements 2. Set the array to random numbers between 0 to 100 inclusive. Don't seed the random number generator. 3. Output the array. 4. Sort the array in ascending order using the selection sort. 5. Output the sorted array. Required IO: Array by F. Last Original: 1 5 ... 2 10 + Sorted: 1 2 ... 5 10 ( +

Answers

#include <iostream> #include <cstdlib> #include <ctime>  using namespace std;  void selection_sort(int arr[], int size) {     for (int i = 0; i < size; ++i) {         int minIndex = i;         for (int j = i + 1; j < size; ++j) {             if (arr[j] < arr[minIndex]) {                 minIndex = j;             }         }         int temp = arr[minIndex];         arr[minIndex] = arr[i];         arr[i] = temp;     } }  int main() {     srand(time(NULL));     int size = 30;     int arr[30];      for (int i = 0; i < size; ++i) {         arr[i] = rand() % 101;     }      cout << "Array by F. Last" << endl;      cout << "\n\nOriginal:\n";     for (int i = 0; i < size; i++) {         cout << arr[i] << " ";     }     cout << endl;      selection_sort(arr, size);      cout << "\n\nSorted:\n";     for (int i = 0; i < size; i++) {         cout << arr[i] << " ";     }     cout << endl;     return 0; } 

Array by F. Last Original: 93 6 52 14 86 32 57 98 85 56 97 35 3 80 44 19 74 25 52 53 14 26 30 42 3 47 88 80 89 66 Sorted: 3 3

.

Similar Solved Questions

1 answer
1. For the following equation, find the center, vertices, foci, transverse axis, and asymptotes, ...
1. For the following equation, find the center, vertices, foci, transverse axis, and asymptotes, and sketch the graph: 2. Consider the set of parametric equations (a) Graph in the following window: TMIN--3.74, TMAX- 3.74, TSTEP = 0.02, XMIN =-10, XMAX = 10, YMIN =-7, YMAX = 7, Sketch the graph. (b) ...
1 answer
Oero ting profit Margins 7. interesst9,000 tax - 9,000 osset tunoues Find ROE ASSETSSALES ASSETSSALES OPM...
Oero ting profit Margins 7. interesst9,000 tax - 9,000 osset tunoues Find ROE ASSETSSALES ASSETSSALES OPM Aug. EQ...
1 answer
Phosphane and arsane analogues of [PtCl2(NH3)2] were prepared in 1934 by Jensen. He reported zero dipole...
Phosphane and arsane analogues of [PtCl2(NH3)2] were prepared in 1934 by Jensen. He reported zero dipole moments for the β isomers, where the designation β represents the product of a synthetic route analogous to that of the ammines. Give the structure of the complexes....
1 answer
You identify a new topoisomerase from a thermophilic bacterium and want to know by what increment...
You identify a new topoisomerase from a thermophilic bacterium and want to know by what increment it changes the linking number of DNA. Outline an experiment by which you could determine whether the enzyme changes Lk in increments of 1, 2 (or more.) Please consider how you would generate the substra...
1 answer
Question 3. When a screw is inserted in the top of a waveguide system operating in...
Question 3. When a screw is inserted in the top of a waveguide system operating in the TE10 mode, it is noticed that this will introduce a VSWR varying from unity to 3.0 for the full range of depth of insertion. That is, with the screw out, the ne; when the screw protrudes the maximum amount, the VS...
1 answer
Write the balanced equation for the reaction of aqueous Pb(ClO3)2 with aqueous Nal. Include phases. chemical equation:...
Write the balanced equation for the reaction of aqueous Pb(ClO3)2 with aqueous Nal. Include phases. chemical equation: What mass of precipitate will form if 1.50 L of highly concentrated Pb(CIO), is mixed with 0.100 L 0.280 M Nal? Assume the reaction goes to completion. mass of precipitate:...
1 answer
LEILU.23.27 Eugenia Bueso-Alas: Attempt 2 UUTUUU-Dye SD Incorrectly Low Question 3 (20 points) An unknown food-dye...
LEILU.23.27 Eugenia Bueso-Alas: Attempt 2 UUTUUU-Dye SD Incorrectly Low Question 3 (20 points) An unknown food-dye is analyzed by the method used in this experiment. The absorbance of 5 standard solutions is plotted vs. their concentration (molarity) and a straight line is obtained with the formula:...
1 answer
Somatic mutations/mosaicism: what does this mean and how can these alter penetrance or expressivity?
Somatic mutations/mosaicism: what does this mean and how can these alter penetrance or expressivity?...
1 answer
This week we discuss the properly classified Balance Sheet. Recall that the value of assets is based on historical cost with few exceptions (short-term investments). Liabilities include values based o...
This week we discuss the properly classified Balance Sheet. Recall that the value of assets is based on historical cost with few exceptions (short-term investments). Liabilities include values based on terms like "likelihood" and "estimatable". So how reliable is the Balance Sheet? P...
1 answer
4. Draw the open-chain carbonyl compounds and the nucleophiles used to form the following nucleophilic addition...
4. Draw the open-chain carbonyl compounds and the nucleophiles used to form the following nucleophilic addition products. a....
1 answer
In a random sample of 21 ​people, the mean commute time to work was33.9 minutes and...
In a random sample of 21 ​people, the mean commute time to work was33.9 minutes and the standard deviation was7.3minutes. Assume the population is normally distributed and use a​ t-distribution to construct a 98​%confidence interval for the population mean mμ. What is the margin...
1 answer
EXAMPLE on tho CANTILEYER METHOD Or LATEIRAL LOADS on FRAMES oblewnry (approximately) fbe reachor...
how to get cross sectional area EXAMPLE on tho CANTILEYER METHOD Or LATEIRAL LOADS on FRAMES oblewnry (approximately) fbe reachorus at Ho base of tte Shouw hous to do termnt lezproxima show how colms of the Fomt shod' n le give. ㄥ 8 /2 fr lok. /6 ft 20A 54a ナ2oft-t.sfrt, 25fr Cr...
1 answer
When the smaller of two consecutive even integers is added to three times the larger, the result is 31
When the smaller of two consecutive even integers is added to three times the larger, the result is 31....
1 answer
A sample of carbon dioxide gas at a pressure of 1.07 atm and a temperature of 166 °C, occupies a volume of 686 mL. If the gas is heated at constant pressure until its volume is 913 mL, the temperature of the gas sample will be ? °C.
A sample of carbon dioxide gas at a pressure of 1.07 atm and a temperature of 166 °C, occupies a volume of 686 mL. If the gas is heated at constant pressure until its volume is 913 mL, the temperature of the gas sample will be ? °C....
2 answers
Find the angle of elevation of the sun when a tower 100m high casts a shadow of 120 meter long
Find the angle of elevation of the sun when a tower 100m high casts a shadow of 120 meter long?...
1 answer
• Distinguish between marginal private cost and marginal social cost • Define marginal damage • Explain...
• Distinguish between marginal private cost and marginal social cost • Define marginal damage • Explain why market efficiency is affected in the case of externalities...
1 answer
*P6.10 (LO6) Lisbon Pottery lost 70% of its inventory in a fire on March 25, 2020....
*P6.10 (LO6) Lisbon Pottery lost 70% of its inventory in a fire on March 25, 2020. The accounting re- cords showed the following gross profit data for February and March. Estimate inventory loss using gross profit method March ba be Net sales Net purchases Freight-in Beginning inventory Ending inven...