Groovy hepcat Marios Fotiou was jivin' on Sat, 07 Nov 1998 20:23:42

+0000 in comp.lang.c.

"Until" Algorithm's a cool scene! Dig it!

Quote:

>Let's say we want to build an algorithm that will do the following

>Lets sugget Xn=a*n

>1. Calculate a value Xn.

>2. Calculate a value X2n by multiplying by 2 the modifier n.

>3. Calculate the value Y(Xn,X2n).

>4. Compare value Y with another W.

>5. Keep on looping UNTIL W>=Y?---That's where I get trouble!

Well, what's the problem? What are you doing that doesn't seem to be

working? Please be specific so we know how to help you.

Quote:

>6. If it reaches that point then prints the value Xn THERE.

>could some one suggest a good implimentation of this algorithm in ANSI C

An easy way to implement a do...until(condition true) construct is

to use do...while(condition not true). Eg.:

int y, w;

do

{

/* calculation of y and w */

Quote:

} while(w < y);

--

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------

http://aardvark.apana.org.au/~phaywood/

============= Ain't I'm a dawg!! ==============