content_image/709464.jpg
are evaluated only once. If in the case of to (down to) the initial value is greater (less) than the final value, the component statement is not executed. If the component statement is executed, it is an error if either the initial value or final value cannot be assigned to the control variable. The control variable is left undefined upon nonnal exit from the for statement. 

program Cosine(Input,Output); { Program 4.6 - Compute the cosine using the expansion: cos (X) = 1 - sqr(X)/(2*1) + sqr(X)*sqr(X)/(4*3*2*1) - ... const Epsilon 1e-7; var Angle: ASquared: Series: Term: I, N: Power: Real Real Real Real Integer Integer { radians }; { Angle squared }; { cosine series }; { next term in series }; { number of cosines to compute }; { power of next term }; begin Readln(Input,N); for I := 1 to N do end begin Readln(Input,Angle); Term := 1; Power:= 0; Series:= 1; ASquared := Sqr(Angle); while Abs(Term) > Epsilon * Abs(Series) do begin Power := Power + 2; Term := -Term * Asquared / (Power*(Power-1)); Series := Series + Term end; Writeln(Output, Angle, Series, Power div 2 { = terms to convergence }) end 

## Produces as results: 

<img src='content_image/709464.jpg'>

