0% found this document useful (0 votes)
2 views2 pages

Ss2 Week 8 Program Example

This document outlines a program for handling student records using sequential file operations. It allows users to input student details, which are then written to a file, and later read back from that file. The program includes prompts for user input and displays the stored records in a clear format.

Uploaded by

chimoskyvibz.14
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Ss2 Week 8 Program Example

This document outlines a program for handling student records using sequential file operations. It allows users to input student details, which are then written to a file, and later read back from that file. The program includes prompts for user input and displays the stored records in a clear format.

Uploaded by

chimoskyvibz.14
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SS2 WEEK 8 PROGRAM EXAMPLE

PROGRAM 1: Sequential File Handling (Simple & Clear)

This program:

• Writes student records using OUTPUT


• Reads them using INPUT

REM =====================================
REM STUDENT RECORD PROGRAM (SEQUENTIAL)
REM =====================================

CLS

REM Declare variables


DIM Name AS STRING
DIM Age AS INTEGER
DIM Class AS STRING
DIM Choice AS STRING

REM Ask user how many records to enter


INPUT "How many students do you want to enter "; N

REM Open file for OUTPUT (Creates new file)


OPEN "[Link]" FOR OUTPUT AS #1

FOR I = 1 TO N

CLS
PRINT "Enter Details for Student "; I
PRINT "----------------------------"

INPUT "Enter Name: ", Name


INPUT "Enter Age: ", Age
INPUT "Enter Class: ", Class

REM Write data to file


WRITE #1, Name, Age, Class

NEXT I
CLOSE #1

PRINT
PRINT "Data Saved Successfully!"
PRINT
INPUT "Press Enter to Read Records ", Choice

CLS

REM Open file for INPUT (Read file)


OPEN "[Link]" FOR INPUT AS #1

PRINT "STUDENT RECORDS"


PRINT "----------------"

DO WHILE NOT EOF(1)

INPUT #1, Name, Age, Class


PRINT "Name: "; Name
PRINT "Age: "; Age
PRINT "Class: "; Class
PRINT "---------------------"

LOOP

CLOSE #1

PRINT
PRINT "End of Program"
END

You might also like