#include #include const int ARRAY_COLS = 10; const int ARRAY_ROWS = 3; void printArray(int myArr[][ARRAY_COLS]) { } for (int i = 0; i < ARRAY_ROWS; i++) { for (int j = 0; j < ARRAY_COLS; j++) { std::cout << myArr[i][j] << ", "; } std::cout << "\n"; This function currently sets the upper-left-hand corder of the 2D array to 999 Instead, this should set all 4 corners of the 2-D array to zero. */ void zeroCorners(int myArr[][ARRAY_COLS]) { } } myArr[0][0] = 999; This function should Loop through every element in the 2-D array. If an element is odd, then subtract one from it to make it even. HINT: function printArray() is an example of Looping through every element in 2D array void makeEven (int myArr[][ARRAY_COLS]) { // TODO - put code here } int main() { int arr[][ARRAY_COLS] { {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, 30), }; std::cout << "Before: \n"; printArray(arr); zeroCorners (arr); makeEven(arr); std::cout << "\nAfter: \n"; printArray(arr);

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
```cpp
#include <iostream>
#include <string>

const int ARRAY_COLS = 10;
const int ARRAY_ROWS = 3;

void printArray(int myArr[][ARRAY_COLS])
{
    for (int i = 0; i < ARRAY_ROWS; i++)
    {
        for (int j = 0; j < ARRAY_COLS; j++)
        {
            std::cout << myArr[i][j] << ", ";
        }
        std::cout << "\n";
    }
}

/*
This function currently sets the upper-left-hand corner of the 2D array to 999
Instead, this should set all 4 corners of the 2-D array to zero.
*/
void zeroCorners(int myArr[][ARRAY_COLS])
{
    myArr[0][0] = 999;
}

/*
This function should loop through every element in the 2-D array.
If an element is odd, then subtract one from it to make it even.
HINT: function printArray() is an example of looping through every element in 2D array
*/
void makeEven(int myArr[][ARRAY_COLS])
{
    // TODO - put code here
}

int main()
{
    int arr[][ARRAY_COLS] = {
        {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, 30},
    };
    std::cout << "Before:\n";
    printArray(arr);

    zeroCorners(arr);
    makeEven(arr);

    std::cout << "\nAfter:\n";
    printArray(arr);
}
```

### Explanation:

1. **Headers and Constants**:
   - The code includes `<iostream>` and `<string>` for input and output operations.
   - Constants `ARRAY_COLS` and `ARRAY_ROWS` define the dimensions of a 3x10 array.

2. **printArray Function**:
   - This function loops through a 2D array and prints each element.
   - Nested loops iterate over rows and columns, printing each element of the array followed by a comma.

3. **zeroCorners Function**
Transcribed Image Text:```cpp #include <iostream> #include <string> const int ARRAY_COLS = 10; const int ARRAY_ROWS = 3; void printArray(int myArr[][ARRAY_COLS]) { for (int i = 0; i < ARRAY_ROWS; i++) { for (int j = 0; j < ARRAY_COLS; j++) { std::cout << myArr[i][j] << ", "; } std::cout << "\n"; } } /* This function currently sets the upper-left-hand corner of the 2D array to 999 Instead, this should set all 4 corners of the 2-D array to zero. */ void zeroCorners(int myArr[][ARRAY_COLS]) { myArr[0][0] = 999; } /* This function should loop through every element in the 2-D array. If an element is odd, then subtract one from it to make it even. HINT: function printArray() is an example of looping through every element in 2D array */ void makeEven(int myArr[][ARRAY_COLS]) { // TODO - put code here } int main() { int arr[][ARRAY_COLS] = { {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, 30}, }; std::cout << "Before:\n"; printArray(arr); zeroCorners(arr); makeEven(arr); std::cout << "\nAfter:\n"; printArray(arr); } ``` ### Explanation: 1. **Headers and Constants**: - The code includes `<iostream>` and `<string>` for input and output operations. - Constants `ARRAY_COLS` and `ARRAY_ROWS` define the dimensions of a 3x10 array. 2. **printArray Function**: - This function loops through a 2D array and prints each element. - Nested loops iterate over rows and columns, printing each element of the array followed by a comma. 3. **zeroCorners Function**
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education