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 31 32 33 34 | #include <stdio.h>
#include <stdlib.h>
void count(int n) {
int i = 0; // TO HERE (D) ... any way you can
printf("We will count from 1 to %d.\n", n); // START HERE (line 5)
while(i < n) {
printf("∙ %d\n", i); // TO HERE (A) ... same behavior
i++;
}
printf("We made it to %d.\n", i); // TO HERE (B) ... same behavior
}
int main(int argc, char* argv[]) {
count(5);
return EXIT_SUCCESS; // TO HERE (C) ... same behavior
}
// A: n → n OR u 8 OR b 8 → c → [delete 1]
//
// until is like two commands in one. Without an argument, it just moves
// down like next, but ignoring the ends of loops.
//┌──────────────────────────────────────────┐
//│ INSTRUCTIONS: Write the most efficient │
//│ way you can think of with GDB commands │
//│ to get from line 5 to A, B, C, and D. |
//└──────────────────────────────────────────┘
// NOTE: This while loop could almost be a for. for is usually preferred.
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */
|
© Copyright 2020 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.