SLC QBASIC FILE HANDLING COMPUTER SCIENCE SUPPLIMENTARY SLC 2065, 2066, 2067, 2068, 2069
1. A sequential data file called “Marks.dat” contains roll number, name, English, Nepali, and Maths field. Write a program to display all the content of the data file. [SLC 2065 SUPPLEMENTARY]
OPEN “Marks.dat” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT#1, R, N$, E, N, M
PRINT R, N$, E, N, M
WEND
CLOSE#1
END
2. A data file “LIB.TXT” consists of book’s name, author’s name and price of books. Write a program to count and display the total number of records present in the file. [SLC 2066 SUPPLEMENTARY]
OPEN “LIB.TXT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT #1, BN$, A$, P
C=C+1
WEND
PRINT “TOTAL NUMBER OF RECORDS=”;C
CLOSE#1
END
3. A sequential data file called ‘MARKS.DAT’ contains ROLL NO, NAME, English, and Nepali and Maths fields. Write a program to display all the contents of the data file. [SLC 2067 SUPPLEMENTARY]
OPEN “MARKS.DAT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT#1, R, N$, E, N, M
PRINT R, N$, E, N, M
WEND
CLOSE#1
END
4. Write a program to view those records from “Employee.dat” sequential data file having employee’s name, department, appointment date and salary whose salary is more than Rs.5000.[SLC 2068 SUPPLEMENTARY]
OPEN “Employee.dat” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT#1, N$, D$, A$,S
IF S>5000 THEN
PRINT N$, D$, A$, S
END IF
WEND
CLOSE#1
END
5. A sequential data file “Staff.dat” contains the name, address, post and salary of the employees. Write a program to read and display all the records stored in the above data file. [SLC 2069 SUPPLEMENTARY]
OPEN “Staff.dat” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT#1, N$, A$, P$, S
PRINT N$, A$, P, S
WEND
CLOSE#1
END
Comments