Skip to content

Commit bf84da2

Browse files
authored
Merge pull request #293 from habibasorour/issue_289_comment
Issue 289 fixed: add comments to 5.2
2 parents 4758771 + fec9de2 commit bf84da2

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

source/ch5_loopsanditeration.ptx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ public class StringIterationExample {
180180
<program interactive="activecode" language="python">
181181
<code>
182182
i = 5
183-
while i &gt; 0:
183+
while i &gt; 0: # while i is greater than 0
184184
print(i)
185-
i = i - 1
185+
i = i - 1
186186
</code>
187187
</program>
188188
</listing>
@@ -195,10 +195,10 @@ while i &gt; 0:
195195
<code>
196196
public class WhileLoopExample {
197197
public static void main(String[] args) {
198-
int i = 5;
199-
while (i &gt; 0) {
198+
int i = 5;
199+
while (i &gt; 0) { // while i is greater than 0
200200
System.out.println(i);
201-
i = i - 1;
201+
i = i - 1;
202202
}
203203
}
204204
}
@@ -218,10 +218,10 @@ public class WhileLoopExample {
218218
<code>
219219
public class DoWhileExample {
220220
public static void main(String[] args) {
221-
int i = 10;
222-
do {
221+
int i = 10;
222+
do { // do-while loop, will run at least once no matter the condition
223223
System.out.println("This runs once, i = " + i);
224-
} while (i &lt; 5);
224+
} while (i &lt; 5); // while i is less than 5
225225
}
226226
}
227227
</code>

0 commit comments

Comments
 (0)