PASCAL


  ITERATIVE INSTRUCTIONS.

Iteration (Latin iteratio – repetition) – repetition activity (usually multiple) the same instruction (or multiple instructions) in a loop.


  LOOP „while”

   while condition do instructions;


We use it when we do not know the exact number of repetitions, but it is possible that the given instruction will not be executed even once. Instructions are executed as long as the condition is true.
Example:

  var x: real;
  begin
  write ('Enter a numeric factor.');
  readln (x);
  while (x<= 0) or (x>=1) do
   begin
   writeln ('The value given is incorrect. ');
   write (' Enter a number from the interval (0;1)');
   readln (x);
  end;
  end.



Stopping the loop while:

  var a,b,c, delta: real;
  begin
  while true do
   begin
   writeln('a=0 - stop');
   write('a='); readln(a);
   if a=0 then Break else
   begin
   write('b='); readln(b);
   write('c='); readln(c);
   delta:=b*b-4*a*c;
   writeln('delta=',delta :0 :2);
   end;
   end;
  end.

The program calculates the „delta” of the square equation