notes/education/software development/ECE1400/Chapter 6 Exercises.md
2024-09-24 22:06:16 -06:00

656 B

  1. What output does the following program fragment produce?
i = 1;
while (i <= 128) {
	printf("%d ", i);
	i *= 2;
}

Output:

1 2 4 8 16 32 64 128
  1. What output does the following program fragment produce?
i = 9384
do {
	printf("%d ", i);
	i /= 10;
} while (i <= 128);

Output:

9384 938 93 9
  1. What output does the following for statement produce?
for (i = 5, j = i - 1; i > 0, j > 0; --i, j = i - 1)
	printf("%d ", i);

Output:

5 4 3 2
  1. Which one of the following statements is not equivalent to the other two (assuming that the loop bodies are the same?)
(a) for (i = 0; i < 10)