Skip to content

Commit 6c7aa64

Browse files
committed
add listing tags
1 parent 296cd38 commit 6c7aa64

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

source/ch5_loopsanditeration.ptx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,22 @@ public class StringIterationExample {
176176
Both Python and Java support the <c>while</c> loop, which continues to execute as long as a condition is true.
177177
Here is a simple example in Python that counts down from 5:
178178
</p>
179-
<program xml:id="python-countdown" interactive="activecode" language="python">
179+
<listing xml:id="python-countdown">
180+
<program interactive="activecode" language="python">
180181
<code>
181182
i = 5
182183
while i &gt; 0:
183184
print(i)
184185
i = i - 1
185186
</code>
186187
</program>
188+
</listing>
187189

188190
<p>
189191
In Java, we add parentheses and curly braces. Here is the same countdown loop in Java:
190192
</p>
191-
<program xml:id="java-countdown" interactive="activecode" language="java">
193+
<listing xml:id="java-countdown">
194+
<program interactive="activecode" language="java">
192195
<code>
193196
public class WhileLoopExample {
194197
public static void main(String[] args) {
@@ -201,6 +204,7 @@ public class WhileLoopExample {
201204
}
202205
</code>
203206
</program>
207+
</listing>
204208

205209
<p><idx><c>do-while</c> loop</idx>
206210
Java adds an additional, if seldom used variation of the <c>while</c> loop called the <c>do-while</c> loop.
@@ -209,8 +213,8 @@ public class WhileLoopExample {
209213
Some programmers prefer this loop in some situations because it avoids an additional assignment prior to the loop.
210214
For example, the following loop will execute once even though the condition is initially false.
211215
</p>
212-
213-
<program xml:id="java-do-while" interactive="activecode" language="java">
216+
<listing xml:id="java-do-while">
217+
<program interactive="activecode" language="java">
214218
<code>
215219
public class DoWhileExample {
216220
public static void main(String[] args) {
@@ -222,6 +226,8 @@ public class DoWhileExample {
222226
}
223227
</code>
224228
</program>
229+
</listing>
230+
225231
</section>
226232
<section xml:id="chapter5_summary">
227233
<title>Summary &amp; Reading Questions</title>

0 commit comments

Comments
 (0)