vault backup: 2024-09-24 22:11:16
This commit is contained in:
parent
28b7389515
commit
e8787230fe
@ -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)
|
||||
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.
|
Loading…
Reference in New Issue
Block a user