From e8787230feeb5981eafd1607e4ccaebe331b9bc4 Mon Sep 17 00:00:00 2001 From: zleyyij <75810274+zleyyij@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:11:16 -0600 Subject: [PATCH] vault backup: 2024-09-24 22:11:16 --- .../ECE1400/Chapter 6 Exercises.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/education/software development/ECE1400/Chapter 6 Exercises.md b/education/software development/ECE1400/Chapter 6 Exercises.md index 3c141b4..ddd8f47 100644 --- a/education/software development/ECE1400/Chapter 6 Exercises.md +++ b/education/software development/ECE1400/Chapter 6 Exercises.md @@ -39,5 +39,20 @@ Output: > 4. Which one of the following statements is not equivalent to the other two (assuming that the loop bodies are the same?) ```c -(a) for (i = 0; i < 10) -``` \ No newline at end of file +for (i = 0; i < 10; i++) // (a) +for (i = 0; i < 10; ++i) // (b) +for (i = 0; i ++ < 10; ) // (c) +``` + +Answer: +C is not the same as A and B, because the increment takes place before the loop body is executed. + +> 5. Which one of the following statements is not equivalent to the other two (assuming that the loop bodies are the same)? +```c +while (i < 10) {...} // (a) +for (; i < 10;) {...} // (b) +do {...} while (i < 10); // (c) +``` + +Answer: +C is not the same as A and B, because the block is executed before the condition is checked. \ No newline at end of file