program WhileExample(Input,Output); Program 4.2 - Compute the Nth partial sum of the harmonic series H(N) = 1 + 1/2 + 1/3 + ... + l/N using a while statement for iteration. } var N: Integer; H: Real; begin Read(Input,N); Write (Output,N) ; H : = 0; while N > 0 do begin H := H + l/N; N end; Writeln(Output,H) end . N - 1 

## Produces as results: 

10 2.928968E+00 program Exponentiation (Input, Output); { Program 4.3 - Compute power(X,Y) = "X raised to the power y" using natural exponent. } var Exponent, Y: Integer; Base, Result, X: Real; begin Read(Input,X,Y); Writeln(Output,X,Y); Result := 1; Base:= X; Exponent:= Y; while Exponent > 0 do begin {Result*power(Base,Exponent) power(X,Y), Exponent > 0 } while not Odd (Exponent) do begin Exponent :~ Exponent div 2; Base .- Sqr(Base) end; Exponent .- Exponent-I; Result:= Result * Base end; Writeln(Output,Result) { Result = power(X,Y) end . 

## Produces as results: 

2.000000E+00 1.280000E+02 7 

