A novice programmer may not yet be familiar with one useful while loop. This is a typical cyclic operation in a Pascal environment. It is convenient to use in various tasks, therefore, we will analyze how this cycle can be included in the program .
The While Pascal cycle requires the following format:
- While (Condition) do (begin if necessary).
- Action algorithm.
- End (if there is a begin command).
- "" . Integer (d<100), boolean (t=True) string (tex='hello'). "begin" , . , , While . , , , . "end", , , "begin".
, . , n . n ( ). . , , n. , , , . i. "1". . , . , - n. . k. i. k . . .
Readln(n); ' - n.
i:=1; k:=0; ' - , .
While i<=n do begin ' - .
k:=k+i; i:=i+1; ' - , .
end; ' - While.
Writeln(k); - .
. , n , . . n, While, . . , . . , , ( ). : , n. , , While Pascal . , , . "Pause Break". c.
Readln(n);
c:=1;
While c<=n do begin ' - .
Readln(a[c]); c:=c+1; ' - , .
end; ' - .
c:=1; ' - .
While c<=n do write(a[c]); ' - n .
n , . While . , . , .