Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

ñïðàâêà, implementation, servlet, reusing, ïðÿìîå âêëþ÷åíèå, external, tasks, class, USB, not, îò÷åò, array, íàâó÷àëüíû çáîðíiê ïà ïðàãðàìàâàííþ
 

for valuable work you must have JavaScript (allow active content)

Pascal. Pa.32. Nest of tasks. Files

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.1     Answer

File 'a.num' contains the sequence of numbers 1,2,3,4,5. Determine position of file pointer after executing the following operators:


      assign(f,'a.num');            reset(f);
      read(f,j);            read(f,j);

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.2     Answer

File 'a.num' contains the sequence of numbers 1,2,3,4,5. Determine position of file pointer after executing the following operators:


      assign(f,'a.num');            reset(f);
      read(f,j);      read(f,j);      read(f,j);
      for i:=1 to j do read(f,k);

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.3     Answer

File 'a.num' contains numbers 1,2,3,4,5. Determine number produced by the following program.


program RR;
    var
    f : file of integer;
    x, z : integer;
begin
    assign(f,'a.num');        reset(f);
    read(f,x);    read(f,x);    z:=0;
    while not eof(f) do begin
        read(f,x);    z:=z+x;
    end;
    close(f);    writeln(z);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.4     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    write(f,1);
    write(f,2);
    write(f,3);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.5     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    write(f,2);
    write(f,2);
    write(f,3);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.6     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    write(f,1);
    write(f,1);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.7     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
    k : integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    for k:=1 to 4 do write(f,k);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.8     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
    k : integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    for k:=5 to 7 do write(f,k);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.9     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
    k : integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    for k:=1 to 4 do write(f,6);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.10     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
    k : integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    for k:=1 to 2 do write(f,10);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.11     Answer

Determine the content of the file xxx.zzz after executing the following program


Program AA;
var
    f : file of integer;
begin
    assign(f,’xxx.zzz’);    rewrite(f);
    close(f);
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.12     Answer

Wite program which creates file of integer containing one hundred numbers 7.


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.13     Answer

Write a program for finding sum of all numbers contained in file of integer.


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.14     Answer

Write a program for union of two files of char.


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.15     Answer

Write a program for determining quantity of components in file of integer.


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.16     Answer

Write a program for finding quantity of char 'z' in file 'a.txt'.


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.17     Answer

Write program for creating file of integer 'b.num' from file 'a.num' by throwing out negative numbers.


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.18     Answer

Write program for determining is equal contents of files of char 'a.txt' and 'b.txt' or not.


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pa.32.19     Answer

Write program for finding maximum number stored in file of integer 'a.num'.


 

©   Aliaksandr Prykhodzka    1993 - 2007