Question
Learning Objective: Multi-dimensional Array and Nested for loop Problem: Start a new Arduino sketch and initialize Serial Monitor. Type following code in setup() function: 0 10 20 30 40 50 60 70 80 90 int table[2][2] = {{1, 2}, {3,4}}; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { Serial.print(table[i][j]); Serial.print("\t"); } Serial.println(); } The code above declares a 2x2 multi-dimensional int array. A multi-dimensional array is "an array of arrays". You can visualize it as a table. Nested for loops (loop within a loop) are used to access the members of the multi-dimensional array. Upload the code and open Serial Monitor to observe output. Walk through the code and output. Make sure you understand how the program is working. Now modify the code so that it displays following output. ME435L Homework 3 - Table Display 1 11 21 31 41 51 61 71 81 91 2 12 22 32 42 52 62 72 82 92 3 13 23 33 43 53 63 73 83 93 4 14 24 34 44 54 64 74 84 94 5 6 15 16 25 26 35 36 45 46 55 56 65 66 75 76 85 86 95 96
Question image 1