Programming in C - While you're Doing this.....



As normal in computer programming, there is ALWAYS more than one right answer to evrery problem. In BASIC, the FOR/NEXT loop was a great way to count repetitions. ( This is the same as the FOR/DO loop in other languages ). This could also be done via another method though - using an IF/THEN statement combination:



*Note that in some versions of BASIC, the THEN is optional in line 20.

In other computing languages, such as FORTRAN and COBOL, a WHILE-DO combination would be used instead of IF-THEN. C is no exception.

Here is the same counting program in the previous lesson, as before, except using WHILE-DO loop for the couning of 1-32:



Whew! That's beggining to get a bit complicated eh? Well hold on to your horses.... cause it's TEST TIME! Yuppers.

Here's your test:

Rewrite the same program, but you are NOT allowed to use any "for" statements. You are only allowed to use the DO-WHILE statement combinations. Go ahead and write it, compile it (wcc) and link it (wlink), and run it. After you fix your bugs, and get it to run correctly, THEN peek over to the next page to find the answer........
On The Following Indicator...
( GREEN will indicate your current location)
1 2 3 4 5 6 7 8 9 10
11

[ ElectronicsTheory.Com ]


THINK FREELY!  Keep Electronics Education Free for the masses by buying form the EE store!




This Course was written by Ray Dall © All Rights Reserved.
This page and all it's content Copyright, Trademarks, Intellectual Properties
and other legal issues 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Ray Dall.
All Rights Reserved.
And for what it's worth... this page was last updated HexDate 01-11--7D1

VISITORS:
Add Me!