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

back

Solution to exercise 5.1.1

<sxh c> N = 20; x = floor(N*rand());

printf(“Guess an integer number in range <0,%d>\n”,N);

while 1

g = input("Your gueess : ");
if x == g 
  disp("Congratulations, this is the right guess.");
  exit(0);
endif

endwhile </sxh>

<texit> \begin{lstlisting} N = 20; x = floor(N*rand());

printf(“Guess an integer number in range <0,%d>\n”,N);

while 1

g = input("Your gueess : ");
if x == g 
  disp("Congratulations, this is the right guess.");
  exit(0);
endif

endwhile \end{lstlisting} </texit>