Write an Pascal Program For Reading from a File - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Saturday, September 23, 2017

Write an Pascal Program For Reading from a File

Pascal: Reading from a File

Program:
program DataFiles;
type
StudentRecord = Record
s_name: String;
s_addr: String;
s_batchcode: String;
end;
var
Student: StudentRecord;
f: file of StudentRecord;

begin
assign(f, 'students.dat');
reset(f);
while not eof(f) do

begin
read(f,Student);
writeln('Name: ',Student.s_name);
writeln('Address: ',Student.s_addr);
writeln('Batch Code: ', Student.s_batchcode);
end;

close(f);
end.

Output:
Name: John Smith
Address: United States of America

Batch Code: Computer Science

No comments:

Post a Comment