Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q: Write a program that will perform various 2D array operations. ( C++! not Java) First, use the populateArray function that we've used in class

Q: Write a program that will perform various 2D array operations. ( C++! not Java)

First, use the populateArray function that we've used in class to populate a 10x10 array with random numbers in the range of 1-1000. Then, create and populate a second 10x10 array using the same function.

Create a third 10x10 array. Write a function that has three 10x10 arrays as its parameters. Your function will simply add corresponding elements in array1 and array2 and place the total in array3. For example:

 array3[3][5] = array1[3][5] + array2[3][5] 

As another example, suppose these numbers below represent 2x2 arrays. The third array is simply the sum of the corresponding elements in the first and second arrays:

 array1: array2: array3: 3 5 6 8 9 13 4 11 10 3 14 14 

Your function call would look something like this:

 addArrays(array1, array2, array3); 

Next, write a function that takes a 2D array as its parameter. The function will return the highest value in the 2D array. Similarly, write an additional function that will return the smallest value in the 2D array.

Make sure to use the printArray function that we've used repeatedly in class to print your 2D arrays.

Your output should look practically identical to this (of course, I have different random numbers):

Array1: 18 380 962 263 14 328 712 960 813 467 832 922 710 331 188 682 105 795 194 851 521 159 766 983 788 739 589 695 112 3 235 500 488 657 840 182 464 290 623 709 253 282 295 799 376 225 93 153 493 885 697 865 159 818 24 67 23 320 994 491 252 709 405 947 501 378 98 757 181 681 406 451 822 255 579 556 833 759 360 466 588 104 695 362 837 839 526 276 694 688 968 172 34 209 564 903 80 895 406 90 Array2: 349 446 493 616 718 819 813 2 847 284 821 388 421 154 660 118 867 709 160 64 19 777 287 529 506 857 617 82 425 337 574 486 410 687 996 757 712 717 723 913 978 616 757 504 825 357 432 268 584 381 566 544 387 142 863 92 203 396 685 474 378 143 704 57 57 671 779 10 50 5 103 105 275 732 894 286 880 40 683 61 580 502 64 411 601 572 904 427 454 266 638 496 648 65 502 811 317 123 618 166 Array3: 367 826 1455 879 732 1147 1525 962 1660 751 1653 1310 1131 485 848 800 972 1504 354 915 540 936 1053 1512 1294 1596 1206 777 537 340 809 986 898 1344 1836 939 1176 1007 1346 1622 1231 898 1052 1303 1201 582 525 421 1077 1266 1263 1409 546 960 887 159 226 716 1679 965 630 852 1109 1004 558 1049 877 767 231 686 509 556 1097 987 1473 842 1713 799 1043 527 1168 606 759 773 1438 1411 1430 703 1148 954 1606 668 682 274 1066 1714 397 1018 1024 256 Array1 largest: 994 Array1 smallest: 3 Array2 largest: 996 Array2 smallest: 2 Array3 largest: 1836 Array3 smallest: 159 Program ending. 

printArray and populateArray here!

void populateArray(int tempArray[][COLS]) {

int temprand = 0;

for (int i = 0; i < ROWS; i++)

for (int j = 0; j < COLS; j++) {

temprand = (rand() % MAXRAND + 1);

tempArray[i][j] = temprand;

void printArray(int tempArray[][COLS]) {

for (int i = 0; i < ROWS; i++) {

for (int j = 0; j < COLS; j++)

cout << setw(5) << tempArray[i][j];

cout << endl;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

Students also viewed these Databases questions

Question

using signal flow graph

Answered: 1 week ago