Loops and data conversion
Repetition: unconditional jumps
Repetition occurs prominently in many programming applications; C provides a number of particularly attractive and elegant constructions. In Figure 2.1, we require the main body of the program to be repeated indefinitely. One possible construction which avoids using the infamous ‘goto’ is:
This is a for( ) loop which has no initial condition, no terminating condition and no action which is applied on each iteration of the loop. Since there is no terminating condition, it does not ever terminate; it is a forever loop.
Figure 2.1 A simple flow diagram to light an LED
The program ...
Get Interfacing with C, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.