Algorithm for main module
Algorithm for main module
Step 1: start
Step 2 : declare required procedure
Step 3: call sub procedure in mainmodule
Step 4: display menu as following
1. Add new record
2. Delete record
3. Search record
4. Delete record
5. Update record
6. Exit
Step 5: stop
Algorithm for adding record
Step 1: start
Step 2: open datafile “STD.DAT” in APPEND mode
Step 3: get ID, N$, C, A$, T# OF Student.
Step 4: store all data in datafile
Step 5: does the user want to add more record?
{Y: go to step 3}
Step 6: stop
Algorithm for deleting record
Step 1: start
Step 2: open datafile “STD.DAT” in input mode and a new datafile “TEMP.DAT” in output mode
Step 3: get DR
Step 4: read ID, N$, C, A$, T# OF Student.
Step 5: is ID equal to DR?
{No: store record in data file “TEMP.DAT}
Step 6: Are all records read from file “STD.DAT”?
{No: Go to step 4}
Step 7: close both files. Delete “STD.DAT” file and rename “TEMP.DAT ” as “STD.DAT”
Step 8: Stop
Step 2: open datafile “STD.DAT” in input mode.
Step 3: Display Id, name, class, address, telephone
Step 4: read ID, N$, C, A$, T# OF Student.
Step 5: Display ID, N$, C, A$, T#
Step 6: Are all read from file “STD.DAT”
{No: Go to step 4}
Step 7: stop
Algorithm for searching record
Step 1: start
Step 2: open datafile “STD.DAT” in input mode
Step 3: get SR$
Step 4: Display Id, name, class, address, telephone
Step 5: read ID, N$, C, A$, T# OF Student.
Step 6: is N$ equal to SR$?
1
{Yes: Display Id, name, class, address, telephone }
Step 7: Are all records read from file “STD.DAT” ?
{No: Go to step 5}
Step 8: close “STD.DAT” datafile.
Step 9: Stop
Algorithm for updating record
Step 1: start
Step 2: open datafile “STD.DAT” in input mode and a new datafile “TEMP.DAT” in output mode
Step 3: get UR
Step 4: read ID, N$, C, A$, T# OF Student.
Step 5: is UD equal to DR?
{No: store record in data file “TEMP.DAT
Yes: get ID, N$, C, A$, T# OF Student. store all data in datafile}
Step 6: Are all records read from file “STD.DAT”?
{No: Go to step 4}
Step 7: close both files. Delete “STD.DAT” file and rename “TEMP.DAT ” as “STD.DAT”
Step 8: Stop