Your program seems to be a savings accumulation program. Here's my solution.
program balanceprog ; { my compiler, TP7.0, does not allow
the use of the word balance
as both a program name and as a variable
so I've changed the name of the program. }
procedure producetable (balance, rate : real) ;
{
balance and rate are the only variables
that need to be passed to the procedure. The only
other variable, lcount, is only used locally
and is declared as such. In any case TP requires that
index counters be declared locally.
}
procedure produceline (balance, rate : real) ;
{
produceline is invoked only by
producetable so it is appropriate to nest
the latter within the former.
}
var
vcount : integer ; { must be local }
begin
write(balance:7:0) ;
write(rate:8:0) ;
for vcount := 1 to 10 do begin
balance:= balance + (balance * rate / 100.0) ;
write(balance:6:0)
end
end ;
var
lcount : integer ;
begin
writeln ('year') ;
write ('balance rate(%)') ;
for lcount := 1 to 10 do
write (lcount:6) ;
writeln ;
for lcount := 1 to 5 do begin
produceline (balance, rate) ;
balance := balance + 100.0 ;
writeln
end
end ;
var
balance, rate : real ; { real fits these variables
better than integer }
begin
writeln ;
write ('enter balance and rate:') ;
read (balance, rate) ;
producetable (balance, rate) ;
writeln
end.