<texit info> author=Roman Putanowicz title=Solution to exercise 4.1.2 </texit>

back

Solution to exercise 4.1.2

The problem can be solved with a simple application of “while” loop: <sxh> L = input(“Give L : ”);

Rd = L; steps = 0; while Rd > 0.1*L;

Rd = Rd * 2.0/3.0
steps=steps+1;

endwhile printf(“One has to make %d steps\n”, steps); </sxh>

<texit> \begin{lstlisting} L = input(“Give L : ”);

Rd = L; steps = 0; while Rd > 0.1*L;

Rd = Rd * 2.0/3.0
steps=steps+1;

endwhile printf(“One has to make %d steps\n”, steps); \end{lstlisting} </texit>