File Handling In QBASIC Programming Example Class 10 Computer Science
CLS
DO WHILE NOT EOF (1)
INPUT#1, NAME$, POST$, SALARY
TAX= (15/100) * SALARY
PRINT NAME$, POST$, SALARY, TAX
LOOP
CLOSE # 1
END
2. A sequential data file called “student.dat” contains some
records under the field’s name, English, Nepali, and Computer. Write a program
to add some more records in the same sequential data file.
OPEN “student.dat” FOR APPEND AS #1
DO
CLS
INPUT “ENTER NAME”; N$
INPUT “ENTER MARKS IN ENGLISH”; E
INPUT “ENTER MARKS IN NEPALI”; N
INPUT “ENTER MARKS IN COMPUTER”; C
WRITE #1, N$, E, N, C
INPUT “DO YOU WANT TO CONTINUE? (Y/N)”; CH$
LOOP WHILE UCASE$(CH$) = “Y”
CLOSE #1
END
3. Write a program to create a data file ‘teldir.dat’ to store
Name, Address and Telephone number of employees according to the need of the
user.
OPEN “teldir.dat” FOR OUTPUT AS #1
DO
CLS
INPUT “ENTER NAME”; N$
INPUT “ENTER ADDRESS”; A$
INPUT “ENTER TELEPHONE NUMBER”; T
WRITE #1, N$, A$, T$
INPUT “DO YOU WANT TO CONTINUE(Y/N)”; CH$
LOOP WHILE UCASE$(CH$) = ”Y”
CLOSE #1
END
4. A sequential data file called “Marks.dat” contains Name, English,
Nepali, Math’s and Science Fields. Write a program to display all the contents
of that data file.
OPEN “Marks.dat” FOR INPUT AS #1
CLS
PRINT “NAME”, “ENGLISH”, “NEPALI”, “MATHS”,
“SCIENCE”
DO WHILE NOT EOF (1)
INPUT #1, N$, E, N, M, S
PRINT N$, E, N, M, S
LOOP
CLOSE #1
END
5. A data file “Salary.Dat” contains the information of employees
regarding their name, post, and salary. Write a program to display all the
information of employees whose salary is greater than 15000 and less than 40000.
OPEN “Salary.dat” FOR INPUT AS #1
CLS
DO WHILE NOT EOF (1)
INPUT #1, N$, P$, S
IF S>15000 AND S<40000 THEN
PRINT N$, P$, S
LOOP
CLOSE #1
END
6. A sequential data file called “Marks.dat” contains NAME, AGE,
CITY, and TELEPHONE fields. Write a program to display all the contents of the
data file.
OPEN “Marks.dat” FOR INPUT AS #1
CLS
DO WHILE NOT EOF (1)
INPUT #1, N$, A, C$, T$
PRINT N$, A, C$, T$
LOOP
CLOSE #1
END
7. Create a data file to store the records of few
employees having Name, Address, Post, Gender and Salary fields. (3)
OPEN “std.dat” FOR
OUTPUT AS #1
CLS
DO
INPUT “Enter Name”; N$
INPUT “Enter Address”;
A$
INPUT “Enter Post”; P$
INPUT “Enter gender”; G$
INPUT “Enter Salary”; S
WRITE #1, N$, A$, P$,
G$, S
INPUT “Do you want to
continue”; CH$
LOOP WHILE UCASE$(CH$) =
”Y”
CLOSE #1
END
8. Write a program to store Roll no., Name, Class,
and Address of any five students.
OPEN “STD.DAT” FOR
OUTPUT AS #1
CLS
FOR I = 1 TO 5
INPUT” ENTER ROLL
NUMBER”; RN
INPUT” ENTER NAME”; N$
INPUT” ENTER CLASS”; C
INPUT” ENTER ADDRESS”;
A$
WRITE #1, RN, N$, C, A$
NEXT I
CLOSE #1
END
9. A data file “STAFF.dat” has stored records of
few employees with EMPID, First name, last name, post and salary. Write a
program to display all the records of the employees whose salary is more than
40,000.
OPEN “STAFF.dat” FOR
INPUT AS #1
CLS
DO WHILE NOT EOF (1)
INPUT #1, ID, F$, L$,
P$, S
IF S > 40000 THEN
PRINT ID, F$, L$, P$, S
LOOP
CLOSE #1
END
Comments
Post a Comment