0

program primo;
uses crt;
type tipo=file of integer;
var scelta:integer;
num:tipo;

procedure inserisci(n:tipo);
var nome,x:string;
i:integer;
begin
write('Nome del file:');
readln(nome);
x:='F:\File\Esercizi\'+nome;
assign(n,x);
rewrite(n);
write('Inserisci 20 numeri:');
for i:=1 to 20 do
write(n,i);
close(n);
end;

procedure scrivi(n:tipo);
var nome,x:string;
i:integer;
begin
write('Nome del file:');
readln(nome);
x:='F:\File\Esercizi\'+nome;
assign(n,x);
reset(n);
while not eof(n) do
begin
read(n,i);
write(i:3);
end;
close(n)
end;

procedure media(n:tipo);


begin
randomize;
repeat
writeln('1)Inserimento');
writeln('2)Lettura');
writeln('3)Media');
writeln('4)Pari');
writeln('5)End');
readln(scelta);
case scelta of
1:inserisci(num);
2:scrivi(num);
5:write('Addio!');
else
write('Scelta non valida!');
end;
until scelta=5;
end.


why it keeps telling me that NUM isn't initialized???

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pyTony
0

num is not set to any value in your program. it is type of file of integer so you are supposed to open one file in your main code and close it at end of it like you do in one of the procedures.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.