Timeline for Pset3. Specifically, what does this code do? Initializing array
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 6, 2016 at 16:42 | vote | accept | gloopit | ||
Jul 6, 2016 at 16:42 | comment | added | gloopit | awesome, thank you so much, Cliff | |
Jul 6, 2016 at 16:34 | comment | added | Cliff B |
no, the inner loop increments from 0 to 1 to 2 and exits. When it exits the inner loop, the outer loop increments once and the inner loop starts over, 0,1,2,exit, and so on. Put the following statement inside your inner loop following the board[][] assignment, compile and run: printf("i=%i, j=%i, total = %i\n", i, j, total);
|
|
Jul 6, 2016 at 16:29 | comment | added | gloopit | So if after the inner gets incremented first, it becomes board[0][1] and then it has --total (7) assigned to it. Then the outer loop is then incremented so it now becomes [1][1], which surely skips [1][0], how does [j] get decremented back to zero for [1][0] and [2][0]? Sorry for the hassle. | |
Jul 6, 2016 at 16:21 | vote | accept | gloopit | ||
Jul 6, 2016 at 16:27 | |||||
Jul 6, 2016 at 16:16 | history | answered | Cliff B | CC BY-SA 3.0 |