Question: Question 5 #include using namespace std; // define a function // pass a 2d array as a parameter void display(float numbers[][2]) { cout < <
Question 5
#include
using namespace std;
// define a function
// pass a 2d array as a parameter
void display(float numbers[][2]) {
cout << "Displaying Values: " << endl;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 2; ++j) {
cout << "num[" << i << "][" << j << "]: " << numbers[i][j] << endl;
}
}
}
int main() {
// initializing the 2 dimensional array.
int actions[3][2] = {
{30, 704},
{70.9, 51.7},
{35.7, 11.92}
};
return 0;
}
a)
The code above contain a nested for loop, briefly explain how a nested for loop works
b)
Modify the actions array in main without touching the dimension or initialization to enable it to be used in the display function
c)
Call the display function in main to show the results of the nested for loop
d) Display and explain your answer.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
