(* control.3.pasc *) (* complex control structures, perform the * 1. if-then-else structure * 2. loop structure * 3. nesting control structure * *) program Control3 is constant nl = '\n'; var a, b, i, j: integer; begin write('Give me two intergers a and b -> '); read(a, b); write(nl); if a = 0 then if b = 0 then write('a=0 and b=0 \n') else if b>0 then write('a=0 and b>0\n') else write('a=0 and b<0\n') endif endif elsif a>0 then if b = 0 then write('a>0 and b=0\n') else if b>0 then write('a>0 and b>0\n') else write('a>0 and b<0\n') endif endif elsif b = 0 then write('a<0 and b=0\n') else if b>0 then write('a<0 and b>0\n') else write('a<0 and b<0\n'); endif endif; write(nl); for i := 1 to 3 loop for j := 1 to 3 loop if i >= j then write(i,' ',j); write(nl); endif; endloop; endloop; write(nl); j := 1; while j <= 3 loop i := j; repeat write(i,' ',j); write(nl); i := i+1; until i > 3; j := j+1; endloop; write(nl); i := 5; while i >= 10 loop write(nl); write('I should not be here....'); write(nl); endloop; i := 1; repeat i := 5*i; write('I shoule be here just once for ', i, nl); until i > 3; end. (* * INPUT: * Give me two intergers a and b -> -4 -5 * OUTPUT * a<0 and b<0 * * 1 1 * 2 1 * 2 2 * 3 1 * 3 2 * 3 3 * * 1 1 * 2 1 * 3 1 * 2 2 * 3 2 * 3 3 * * I should be here just once for 5 *)