#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
2 #include <iostream>
3 #include <string>
4
5
6
7
8 void printArray(int myArr[][ARRAY_COLS])
9- {
10
11-
12
13-
const int ARRAY_COLS = 10;
3;
const int ARRAY_ROWS
14
15
16
17
18 }
19
20- /*
21
26
27 }
37 }
38
44
45
46
47
48
49
50
for (int i = 0; i < ARRAY_ROWS; i++)
{
22
23
*/
24 void zeroCorners (int myArr[] [ARRAY_COLS])
25 - {
myArr[0][0] = 999;
51
52
}
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.
for (int j = 0; j < ARRAY_COLS; j++)
{
std::cout << myArr[i][j] << ", ";
}
28
29 - /*
30 This function should Loop through every element in the 2-D array.
If an element is odd, then subtract one from to make it even.
31
32
HINT: function printArray() is an example of Looping through every element in 2D array
*/
33
34 void makeEven (int myArr[][ARRAY_COLS])
35 - {
36
// TODO - put code here
std::cout << "\n";
53
54 }
55
39 int main()
40 - {
41 -
42
43
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);
Transcribed Image Text:2 #include <iostream> 3 #include <string> 4 5 6 7 8 void printArray(int myArr[][ARRAY_COLS]) 9- { 10 11- 12 13- const int ARRAY_COLS = 10; 3; const int ARRAY_ROWS 14 15 16 17 18 } 19 20- /* 21 26 27 } 37 } 38 44 45 46 47 48 49 50 for (int i = 0; i < ARRAY_ROWS; i++) { 22 23 */ 24 void zeroCorners (int myArr[] [ARRAY_COLS]) 25 - { myArr[0][0] = 999; 51 52 } 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. for (int j = 0; j < ARRAY_COLS; j++) { std::cout << myArr[i][j] << ", "; } 28 29 - /* 30 This function should Loop through every element in the 2-D array. If an element is odd, then subtract one from to make it even. 31 32 HINT: function printArray() is an example of Looping through every element in 2D array */ 33 34 void makeEven (int myArr[][ARRAY_COLS]) 35 - { 36 // TODO - put code here std::cout << "\n"; 53 54 } 55 39 int main() 40 - { 41 - 42 43 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);
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