Gra = String ;
File_Content = Record
Name : Gra;
Matric_No : Gra;
Dept : Gra;
Sex : Gra;
Date_Of_Birth : Gra;
(*enter as many data as you like and intialise either as string, integer or char*);
FileInfo : File_Content;
Newfile : text;
I : Integer;
Assign (newfile, 'Grace_Joseph.txt');
for i := 1 to 5 do
writeln ('Enter name:');
readln ( fileinfo.name);
writeln ('matric number');
writeln ('date of birth');
(*follow the above procedure to write and read the data you initialised* )
writeln (newfile, 'matric number:', fileinfo.matric_no);
writeln (newfile,' Department: ', fileinfo.dept);
writeln (newfile,' Sex:', fileinfo.sex);
writeln (newfile,' Date Of Birth:', fileinfo.date_of_birth);
Logic Of the Program
- First, we follow the same syntax for creating a record in Pascal Programming Language by declaring it.
- Next, we create variables like Name, Matric Number, Sex, Date of Birth and set to a string (GRA) data type because we'll be dealing with alphabets, characters, and numbers here.
- The next section of the program defines the variable 'New File' as a text file that will be called Grace_Joseph.txt in the next section.
- You can rename the name of the textfile from Grace_Joseph.txt to yourDesired Name.txt.
- The program creates a record for 5 students using the For Do loop variable 'i'.
- Once a record has been entered completely for the first student, 'i' is incremented until we have records for all 5 students.
Pascal Arithmetic Program Using IF THEN statement
Pascal Program to Create and Save Records in a Textfile
Pascal program To Calculate Area of a Triangle
Pascal Program of Matrix Multiplication
Pascal Program to Find The Average Of Only Positive Numbers Using While Do loop