|
| 1 | +// PSEUDOCODE FOR DISPLAYING A SINGLE RECORD FROM A FILE |
| 2 | +// This pseudocode demonstrates how to read and display a single student record from a file. |
| 3 | +// It assumes that the file 'sRec.txt' contains student records and each record consists of |
| 4 | +// roll number, name, contact, fee amount, and fee payment status. |
| 5 | +// The pseudocode reads the first record from the file and displays its contents. |
| 6 | + |
| 7 | +// Declare variables to store the student record |
| 8 | +DECLARE sRecord : STRING |
| 9 | +DECLARE rollNo : INTEGER // To store the roll number of a student |
| 10 | +DECLARE sName : STRING // To store the name of a student |
| 11 | +DECLARE sContact : STRING // To store the contact information of a student |
| 12 | +DECLARE sFee : CURRENCY // To store the fee amount |
| 13 | +DECLARE isFeePaid : BOOLEAN // To store the fee payment status |
| 14 | +DECLARE hashPos1, hashPos2 : INTEGER |
| 15 | + |
| 16 | +// Open the file 'sRec.txt' in read mode |
| 17 | +OPENFILE "sRec.txt" FOR READ |
| 18 | + |
| 19 | +// Read the first record from the file line |
| 20 | +READFILE "sRec.txt", sRecord |
| 21 | +hashPos1 = LOCATE('#', sRecord) |
| 22 | +rollNo = LEFT(sRecord, hashPos1-1) |
| 23 | + |
| 24 | +hashPos2 = LOCATE(hashPos1+1, '#', sRecord) |
| 25 | +sName = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1) |
| 26 | + |
| 27 | +hashPos1 = hashPos2 |
| 28 | +hashPos2 = LOCATE(hashPos1+1, '#', sRecord) |
| 29 | +sContact = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1) |
| 30 | + |
| 31 | +hashPos1 = hashPos2 |
| 32 | +hashPos2 = LOCATE(hashPos1+1, '#', sRecord) |
| 33 | +sFee = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1) |
| 34 | + |
| 35 | +hashPos1 = hashPos2 |
| 36 | +hashPos2 = LOCATE(hashPos1+1, '#', sRecord) |
| 37 | +IsFeePaid = MID(sRecord, hashPos1+1, hashPos2-hashPos1-1) |
| 38 | + |
| 39 | +// Output the details of the student record |
| 40 | +OUTPUT "Roll number: ", rollNo |
| 41 | +OUTPUT "Student name: ", sName |
| 42 | +OUTPUT "Student contact: ", sContact |
| 43 | +OUTPUT "Fee amount: ", sFee |
| 44 | +OUTPUT "Is fee paid? ", isFeePaid |
| 45 | + |
| 46 | +// Close the file after reading |
| 47 | +CLOSEFILE "sRec.txt" |
| 48 | + |
| 49 | +/* |
| 50 | + * ──────────────────────────────────────────────────────────────────────── |
| 51 | + * Author: Zafar Ali Khan |
| 52 | + * Position: A and O Level Computer Science Teacher |
| 53 | + * |
| 54 | + * Description: |
| 55 | + * This code is part of my teaching material, created for the betterment of my students |
| 56 | + * and learners worldwide. It's intended to facilitate learning and understanding |
| 57 | + * of computer science concepts. |
| 58 | + * |
| 59 | + * Contact: |
| 60 | + |
| 61 | + * LinkedIn: [https://www.linkedin.com/in/zakonweb](https://www.linkedin.com/in/zakonweb) |
| 62 | + * GitHub: [https://github.com/zakonweb](https://github.com/zakonweb) |
| 63 | + * ──────────────────────────────────────────────────────────────────────── |
| 64 | + */ |
| 65 | + |
0 commit comments