Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 725e756

Browse files
Update README.md
1 parent 5de8b7e commit 725e756

File tree

1 file changed

+59
-71
lines changed

1 file changed

+59
-71
lines changed

‎README.md‎

Lines changed: 59 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -316,104 +316,92 @@ perform various actions such as correcting an error, navigating to a certain
316316
part of a program, etc. That's the power of catching the FALSE result.
317317

318318
## Loops
319-
There are commands or portions of your program
320-
to be repeated several times. Loops are there to do
321-
that. Now, there are simple loops and
322-
loops based on a given condition,
323-
much like a repeated IF statement.
324-
Simple loops are like repeat 10 times or repeat
325-
forever. Conditional loops are loops with
326-
specific conditions other than simple iteration
327-
just like in robot programming:
328-
repeat until color red, repeat until the
329-
distance is less than 50mm, etc.
330-
331-
The most common that we see in computer
332-
programming: the `for` loop,
333-
`while` loop and `do-while` loop.
319+
There are commands or portions of your program to be repeated several times.
320+
Loops are there to do that. Now, there are simple loops and loops based on a
321+
given condition, much like a repeated IF statement. Simple loops are like
322+
"repeat 10 times" or "repeat forever." Conditional loops are loops with
323+
specific conditions other than simple iteration, just like in robot
324+
programming: "repeat until color red," "repeat until the distance is less than
325+
50mm," etc.
326+
327+
The most common loops that we see in computer programming are the `for` loop,
328+
`while` loop, and `do-while` loop.
334329

335330
### Sample Program Using Loops
336-
```
331+
```c
337332
#include <stdio.h>
338333

339334
int main() {
340-
341335
int n = 11;
342-
343336
int i;
344337
int x[n];
345-
printf("the `for` loop: \n");
346-
for (i = 1; i < n; i++) {
347338

348-
printf("iteration: %d | Hello World. \n", i);
339+
printf("The `for` loop:\n");
340+
for (i = 1; i < n; i++) {
341+
printf("Iteration: %d | Hello World.\n", i);
349342
}
350343

351344
int y = 0;
352-
printf("------\n");
353-
printf("the `while` loop:\n");
345+
printf("------\n");
346+
printf("The `while` loop:\n");
354347
while (y < 10) {
355348
y += 1;
356-
printf("iteration: %d | Hello World.\n", y);
349+
printf("Iteration: %d | Hello World.\n", y);
357350
}
358351

359352
y = 0;
360-
361-
printf("------ \n");
362-
printf("the `do while` loop: \n");
363-
353+
printf("------\n");
354+
printf("The `do-while` loop:\n");
364355
do {
365356
y += 1;
366-
printf("iteration: %d | Hello World. \n", y);
367-
}
368-
while (y < 10);
357+
printf("Iteration: %d | Hello World.\n", y);
358+
} while (y < 10);
369359

370360
return 0;
371-
372361
}
373362
```
374363

375-
the result:
364+
The result:
376365
```
377-
the `for` loop:
378-
iteration: 1 | Hello World.
379-
iteration: 2 | Hello World.
380-
iteration: 3 | Hello World.
381-
iteration: 4 | Hello World.
382-
iteration: 5 | Hello World.
383-
iteration: 6 | Hello World.
384-
iteration: 7 | Hello World.
385-
iteration: 8 | Hello World.
386-
iteration: 9 | Hello World.
387-
iteration: 10 | Hello World.
388-
------
389-
the `while` loop:
390-
iteration: 1 | Hello World.
391-
iteration: 2 | Hello World.
392-
iteration: 3 | Hello World.
393-
iteration: 4 | Hello World.
394-
iteration: 5 | Hello World.
395-
iteration: 6 | Hello World.
396-
iteration: 7 | Hello World.
397-
iteration: 8 | Hello World.
398-
iteration: 9 | Hello World.
399-
iteration: 10 | Hello World.
400-
------
401-
the `dowhile` loop:
402-
iteration: 1 | Hello World.
403-
iteration: 2 | Hello World.
404-
iteration: 3 | Hello World.
405-
iteration: 4 | Hello World.
406-
iteration: 5 | Hello World.
407-
iteration: 6 | Hello World.
408-
iteration: 7 | Hello World.
409-
iteration: 8 | Hello World.
410-
iteration: 9 | Hello World.
411-
iteration: 10 | Hello World.
366+
The `for` loop:
367+
Iteration: 1 | Hello World.
368+
Iteration: 2 | Hello World.
369+
Iteration: 3 | Hello World.
370+
Iteration: 4 | Hello World.
371+
Iteration: 5 | Hello World.
372+
Iteration: 6 | Hello World.
373+
Iteration: 7 | Hello World.
374+
Iteration: 8 | Hello World.
375+
Iteration: 9 | Hello World.
376+
Iteration: 10 | Hello World.
377+
------
378+
The `while` loop:
379+
Iteration: 1 | Hello World.
380+
Iteration: 2 | Hello World.
381+
Iteration: 3 | Hello World.
382+
Iteration: 4 | Hello World.
383+
Iteration: 5 | Hello World.
384+
Iteration: 6 | Hello World.
385+
Iteration: 7 | Hello World.
386+
Iteration: 8 | Hello World.
387+
Iteration: 9 | Hello World.
388+
Iteration: 10 | Hello World.
389+
------
390+
The `do-while` loop:
391+
Iteration: 1 | Hello World.
392+
Iteration: 2 | Hello World.
393+
Iteration: 3 | Hello World.
394+
Iteration: 4 | Hello World.
395+
Iteration: 5 | Hello World.
396+
Iteration: 6 | Hello World.
397+
Iteration: 7 | Hello World.
398+
Iteration: 8 | Hello World.
399+
Iteration: 9 | Hello World.
400+
Iteration: 10 | Hello World.
412401
```
413402

414-
As you can see here, it's just printing the
415-
Hello World ten times, whether it's `for` loop,
416-
`while` loop or `do-while` loop.
403+
As you can see here, it's just printing "Hello World" ten times, whether it's
404+
a `for` loop, `while` loop, or `do-while` loop.
417405

418406
## Functions
419407
A function is a group of statements (commands)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /