FOR LOOP STRUCTURE For := to do eg. for I := 1 to 100 do begin writeln(‘This is a loop’); end;
For program example Program loops; var a: integer begin for a := 1 to 10 begin writeln(‘This is loop’, a); readln end; end.
While loop structure while do eg. read (num); while num <> 999 do begin sum := sum + num; writeln(‘the sum is’, sum); read(num); end;
WHILE PROGRAM EXAMPLE program squareroot; var square,num: integer begin read(num); while num <> 999 do begin square := num * num; writeln(‘ The square is’, square); read(num); end; end.
WHILE PROGRAM EXAMPLE program whileloop; var num: integer; begin while num < 25 do begin writeln(‘ this is loop number’ num); num := num +1 readln; end; end.
Repeat Until Loop Structure repeat until eg. repeat writeln(‘this is a loop again’); readln; a:=a +1 until a > 10
Repeat Until Loop Example program password; const password = 1234 var p: integer; begin repeat writeln(‘enter the password’); read(p); until p=password; end.