Sams Teach Yourself C in 21 Days

(singke) #1
Basic Program Control 127

6


10:
11: for (count = 1; count <= 20; count++)
12: printf(“%d\n”, count);
13:
14: return 0;
15: }

1 2 3 4 5 6 7 8 9

10
11
12
13
14
15
16
17
18
19
20
Figure 6.2 illustrates the operation of the forloop in Listing 6.1.

LISTING6.1 continued

OUTPUT

FIGURE6.2
How the forloop in
Listing 6.1 operates.

Assign 1
to count

Increment
count by 1

Start

Is count
< = 20?

Done

Execute
print()

for (count = 1; count < = 20; count++)
print ( "\n%d", count);

NO

YES

10 448201x-CH06 8/13/02 11:20 AM Page 127

Free download pdf