Sequential file access

One of the most frequent operations used on files is to search for a particular record.

Sequential access of records occurs when a number of records need to be successively read.

For example, if a file has records which are not sorted, then to find a particular record, that file would need to be searched from the beginning, reading each record in turn until the wanted record is found.

 

 

Sequential search of a file : To find a record in a file using a sequential search.

Open file;
Repeat
  Read a record
Until required record is found;

 

 

Sequential processing of all records in a file.

Open file;
Repeat
  Read a record;
  Process a record;
Until end of file;