The for: Pascal Starter Cycle

The basis of programming is loops, for example, for. Pascal. Like any computer language, it also contains such constructs in its syntax.

Assignment of cyclic operators

– . , . , – , .

Pascal :

  • for – ;
  • while – ;
  • repeat ... until – .

for pascal




, . . for .

, :

FOR {a} := {b} TO {c} DO {d}.

, . . :





  • {a} – , INTEGER;
  • {b}, {c} – , , {a};
  • {d} – / , .

for, Pascal {b}, {a} := {c}, :

  • {b} <= {c}, ;
  • {d};
  • {a} , {a} := {a} + 1.

pascal for dummies




for , .

, for, , , «».

  • s := 0;
  • for a := 1 to 5 do
  • begin
  • s := s + a;
  • end;
  • writeln(s);

, :

  • 1- : a = 1; s = 1;
  • 2- : a = 2; s = 3;
  • 3- : a = 3; s = 6;
  • 4- : a = 4; s = 10;
  • 5- : a = 5; s = 15.

«15» – 1 5.

, 1 5 .









for, Pascal {a}, {b}, {c}. , . .

  1. ( ) {a} .
  2. {b} {c} . , , 0 p. for a := 0 to pi do.trunc() round(). , – .
  3. {b} < {c}, {d} .
  4. {a} . , {a} <> {c}. : {a} for.
  5. ( do) - , {a}. , .

« » : , . , 2–3 Tab.

for pascal loop




. «» .

, f(x) = 3*x + 15, M [x1; x2], x1 x2 – . for. Pascal :

  • for a := 1 to M do
  • begin
  • x:= x1+(x2–x1)*(a–1)/(M–1);
  • f:= 3*x + 15;
  • writeln (x, ‘ ’, f);
  • end.

x , : x:= x1+(x2–x1)*(a–1)/(M–1).

, , for. Pascal , :

  • FOR {a} := {b} TO {c} DO
  • FOR {a1} := {b1} TO {c1} DO

pascal programming language




, : . , .




All Articles