# (Solved) : Question 9 20 Marks Computer Program Designed Generate 20 Random Integers 1 5 Save Numbers Q42739821 . . .

Question 9._(20 marks) A computer program is designed to generate 20 random integers between 1 and 5, save the numbers in an array, and then write the top three largest numbers to a file. The program is shown below but contains at least 5 errors. In the table on the next page, reference the line number where the error occurs, and write down what is wrong. The line numbers on the left of the page are NOT part of the C++ program, they are included only for identification purposes. Line # Program Code #include <iostream> #include <fstream> using namespace std int main(void) { int i, j, temp, array[20]; ofstream outfile(‘myfile.dat’); if (outfile. fail()) { cout << ” output file opening failedn”; exit (1); for (i=0; i<20; i++) array[i] = rand() *5; for (i=0; i<3; i++) { for (j=1; j<20-i; j++) { if (array[j-1] > array[j]) { temp = array[j-1]; array[j-1] = array[j]; array[j] = temp; for (i=0; i<3; i++) outfile « array[i]; close. file(); return 0; Show transcribed image text Question 9._(20 marks) A computer program is designed to generate 20 random integers between 1 and 5, save the numbers in an array, and then write the top three largest numbers to a file. The program is shown below but contains at least 5 errors. In the table on the next page, reference the line number where the error occurs, and write down what is wrong. The line numbers on the left of the page are NOT part of the C++ program, they are included only for identification purposes. Line # Program Code #include #include using namespace std int main(void) { int i, j, temp, array[20]; ofstream outfile(‘myfile.dat’); if (outfile. fail()) { cout

Answer to Question 9._(20 marks) A computer program is designed to generate 20 random integers between 1 and 5, save the numbers i…

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.