Page 1 of 1

2D Array. The following program has a 2D array to store data. 1* row of the 2D array has 5 integers and 2nd row is the r

Posted: Fri May 20, 2022 5:22 pm
by answerhappygod
2d Array The Following Program Has A 2d Array To Store Data 1 Row Of The 2d Array Has 5 Integers And 2nd Row Is The R 1
2d Array The Following Program Has A 2d Array To Store Data 1 Row Of The 2d Array Has 5 Integers And 2nd Row Is The R 1 (98.92 KiB) Viewed 35 times
2D Array. The following program has a 2D array to store data. 1* row of the 2D array has 5 integers and 2nd row is the reverse array of 1st row. Please fill your answer in the box to have the output as shown below. (10 points) Hint: Don't just assign { 5,4,3,2,1 } to 2nd row directly, or you will get 0 points. #include <iostream> using std::cout; using std::endl; #include <iomanip> using std::setw; sint main() { const int elements = 5; int numbers [2] (elements] = { {1, 2, 3, 4, 5},{0} }; cout << "\nOriginal array:" << endl; for (int i = 0; i < elements; i++) cout << setw(3) << numbers [@]; \\Mac\Home... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 - O х ? Original array: 1 2 3 4 5 The reversed array: 5 4 3 2 1 cout << "\n\nThe reversed array:" << endl; for (int i = 0; i < elements; i++) cout << setw(3) << numbers [1]; cout << endl << endl; system("pause"); return 0; }