bug0134.pp 722 B

12345678910111213141516171819202122232425262728293031
  1. {
  2. In this simple examply, the even loop is wrong. When continue; is called,
  3. it should go back to the top and check the loop conditions and exit when i =
  4. 4, but continue skips checking the loop conditions and does i=5 too, then it
  5. is odd, doesn't run the continue, and the loop terminates properly.
  6. }
  7. procedure demoloop( max:integer );
  8. var i : integer;
  9. begin
  10. i := 1;
  11. while (i <= max) do
  12. begin
  13. if (i mod 2 = 0) then
  14. begin
  15. writeln('Even ',i,' of ',max);
  16. inc(i);
  17. continue;
  18. end;
  19. writeln('Odd ',i,' of ',max);
  20. inc(i);
  21. end;
  22. end;
  23. begin
  24. writeln('Odd loop (continue is *not* last call):');
  25. demoloop(3);
  26. writeln('Even loop (continue is last call):');
  27. demoloop(4);
  28. end.