Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Sunday, February 25, 2024

Important QBasic File Handling Programs for SEE/Grade 10 Exams.

Important QBasic File Handling Programs for SEE/Grade 10 Exams.

(It carries 4 marks)

 

Essential QBasic File Handling Programs for SEE/Grade 10 Exams.

1) SLC 2063

Write a program to store the book's name, writers name and the price of the book in a sequential data file “STORE.DAT”. The program provides the facility to enter more records as long as the user wants.

OPEN “STORE.DAT” FOR OUTPUT AS #2

TOP:

INPUT “Enter book’s name=”;b$

INPUT “Enter Writer’s name=”;w$

INPUT “Enter price of book=”;p

WRITE #2, b$, w$, p

INPUT “Do you want to add more records (Y/N)”;Ans$

IF Ans$=”Y” or Ans$=”y” THEN GOTO top

CLOSE #2

END

 

2) SLC 2064

Write a program in QBASIC to open a sequential data file “WMP.DAT” which contains the employee records, name, address and phone number and display all the records as well as total number of records stored in the file.

OPEN “EMP.DAT” FOR INPUT AS # 1

CLS

P=0

PRINT "Name", "Address", "Phone"

WHILE NOT EOF(1)

INPUT #1, n$, a$, p$

PRINT n$, a$, p$

P=p+1

WEND

PRINT “Total number of records=”;p

CLOSE #1

END

3) Specification Grid 2065

Create a sequential data file "STD.DAT" to store name and marks obtained in Engish, Maths and Science subjects for few students.

OPEN "STD.DAT" FOR OUTPUT AS #2

Top:

CLS

INPUT "Enter name=";n$

INPUT "Enter marks of English=";e

INPUT "Enter marks of Maths=";m

INPUT "Enter marks of Science=";s

WRITE #2, n$, e,m,s

INPUT "Do you want to continue(Y/N)?";Ans$

IF Ans$="y" OR Ans$="Y" THEN GOTO top

CLOSE #2

END

 

4) SLC 2065

Write a program to store records regarding the information of book number, book's name writer's name in a sequential data file called "Library.dat".

OPEN "Library.dat" FOR OUTPUT AS #1

Avn:

INPUT "Enter book number=";n

INPUT "Enter books name=";b$

INPUT "Enter authors name=";a$

WRITE #1,n,b$,a$

INPUT "Store more records?";Ans$

IF Ans$="Y" OR Ans$="y" THEN goto avn

CLOSE #1

END

 

5) SLC supplementary 2065

A sequential data file "MARKS.DAT" contains Roll.no, Name, English, Nepali and Maths fields. Write a program to display all the contents of the data file.

OPEN "MARKS.DAT" FOR INPUT AS #1

CLS

PRINT "Roll no", "Name", "English", "Nepali", "Maths"

DO WHILE NOT EOF(1)

INPUT #1, r, n$, e, n, m

PRINT r, n$, e,n,m

LOOP

CLOSE #1

END

 

6) SLC 2066

WAP to create a sequential data file “employee.dat” to store employee’s name, address, age, gender and salary.

OPEN “employee.dat” FOR OUTPUT AS # 1

DO

INPUT “Enter name”;name$

INPUT “Enter address=”;add$

INPUT “Enter age=”;age

INPUT “Enter gender=”;g$

INPUT “Enter salary=”;sal

WRITE #!, name$, add$, age, g$, sal

INPUT “Do you want to continue..?”;Ans$

LOOP WHILE UCASE$(Ans$) =”y”

CLOSE #!

END

7) SLC supplementary 2066

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.

OPEN "LIB.TXT" FOR INPUT AS #1

CLS

c=0

PRINT "Books name", "Authors name", "Price"

DO WHILE NOT EOF(1)

INPUT #1, b$,a$,p

c=c+1

LOOP

PRINT "Total number of records=";c

CLOSE #1

END

 

8) SLC 2067

A sequential data file "EMP.DAT" contains name, post and salary fields of information about employees. Write a program to display all the information of employees along with tax amount also. (tax is 15% of salary)

OPEN "EMP.DAT" FOR INPUT AS #1

CLS

PRINT "Name", "post", "salary", "tax"

DO WHILE NOT EOF(1)

INPUT #1, n$, p$, s

t = (s * 15) / 100

PRINT n$, p$, s, t

LOOP

CLOSE #1

END

 

 9) A sequential data file "information. dat" have contains name, address and phone no. WAP to display all the information whose address is Hasanpur or Taranagar.

CLS

OPEN "information.dat" FOR INPUT AS #1

DO WHILE NOT EOF(1)

INPUT #1,n$,a$,p

IF a$="Hasanpur" or a$="Taranagar" THEN

PRINT "Name=";n$

PRINT "Address=";a$

PRINT "Phone no=";p

ENDIF

LOOP

CLOSE #1

END

 

10) A data file named "salary.dat" contains name, designation and salary of employees. WAP to display all the employees record whose salary is between 10000 to 15000.

CLS

OPEN "salary.dat" FOR INPUT as #3

DO WHILE NOT EOF(3)

INPUT #3, n$,d$,s

IF s>=10000 and s<=15000 THEN

PRINT "Name="n$

PRINT "Designation=";d$

PRINT "Salary=";s

ENDIF

LOOP

CLOSE #3

END

11) A sequential data file "result.dat" contains name and marks secured by students in 3 subjects. Assuming that pass marks of each subjects is 40, write a program to count the number of passed students.

OPEN "result.dat" FOR INPUT AS #2

DO WHILE NOT EOF(2)

INPUT #2, n$,e,m,c

IF e>=40 and m>=40 and c>=40 THEN

p=p+1

ENDIF

LOOP

CLOSE #2

PRINT "Total number of passed students=";p

END

 

12)  WAP to create a data file "result.dat" and store name, class, roll noand any 3 subjects marks of five students.

CLS

OPEN "result.dat" FOR OUTPUT AS #2

FOR x= 1 to 5

INPUT "Enter name=";n$

INPUT "Enter Roll no.=";r

INPUT "Enter Class=";c$

INPUT "Enter Marks of English=";e

INPUT "Enter Marks of Maths=";m

INPUT "Enter Marks of Computer=";c

WRITE #2, n$,r,c$,e,m,c

NEXT x

CLOSE #2

END

13)    WAP to create a sequential file "store.dat" and store item code, item name, rate. The program should prompt the user to enter more data.

OPEN "store.dat" FOR OUTPUT AS #4

DO

INPUT "Enter item code=";c

INPUT "Enter Item name=";n$

INPUT "enter rate=";r

WRITE #4, c, n$,r

PRINT

INPUT "Do you want to conti……(y/n)";Ans$

LOOP WHILE UCASE$(Ans$)="Y"

CLOSE #4

END

 

14)    SLC 2068

      A sequential data file called ‘student.dat’ contains some records under the fields name, English, Nepali and Computer. Write a 3 program to add some more records in the same sequential data file.

OPEN “student.dat” FOR APPEND AS #1

TOP:

INPUT “Enter name=”;n$

INPUT “Enter English =”;e

INPUT “Enter Nepali=”;n

INPUT “Enter computer=”;c

WRITE #1, n$,E,N,C

INPUT “Do you want more data=”;Ans$

IF Ans$=”Y” OR Ans$= “y” THEN GOTO top

CLOSE #1

END

15) WAP to delete some records from data file "AVN.DAT" which has contents name, class, roll no, and address.

CLS

OPEN "avn.dat" FOR INPUT AS #1

OPEN "abc.dat" FOR OUTPUT AS #2

ab:

DO WHILE NOT EOF(1)

INPUT #1, r,n$,c$,a$

PRINT "Name=";n$

PRINT "Class=";c$

PRINT "Roll no=";r

PRINT "Address=";a$

INPUT "Do you want to delete this record (y/n)";y$

IF y$="Y" or y$="y" THEN GOTO ab

ELSE

WRITE #2, r, n$, c$, a$

GOTO ab

ENDIF

LOOP

CLOSE #1, #2

KILL "avn.dat"

NAME "abc.dat" AS "avn.dat"

END

 

16) Write a program to create a data file "record.dat" to add and display the records with the help of a menu base structure.

CLS

PRINT "MAIN MENU"

PRINT "1. Add records"

PRINT "2. Display records"

PRINT : PRINT

INPUT "Enter your choice: (1/2)";ch

SELECT CASE ch

CASE 1

CALL addrecord

CASE 2

CALL disprecord

END SELECT

END

SUB addrecord

CLS

OPEN "record.dat" FOR APPEND AS #1

DO

INPUT "Enter name=";n$

INPUT "Enter class=";c$

INPUT "Enter Roll no=";r

WRITE #1,n$,c$,r

INPUT "Do you need more records to add=";Ans$

LOOP WHILE UCASE$(Ans$)="Y"

CLOSE #1

END SUB

SUB disprecord

CLS

OPEN "record.dat" FOR INPUT AS # 1

PRINT "Students Name","Class", "Roll no"

DO WHILE NOT EOF(1)

INPUT #1,n$,c$,r

PRINT n$,c$,r

LOOP

CLOSE #1

END SUB

17)    A sequential data file “STUDENT.DAT” contains the details of students such as Name, roll no, class, joining date etc. WAP to update the details of the data file “student.dat”.

CLS

OPEN “student.dat” FOR INPUT AS#1

OPEN “temp.dat” FOR OUTPUT AS #2

WHILE NOT EOF(1)

INPUT #1, name$, roll, class, date$

PRINT:PRINT

PRINT “Name of the student=”;name$

PRINT “Roll number”;roll

PRINT “Class=”;class

PRINT “Joining date=”;date$

PRINT:PRINT

PRINT “Do you want to Update this record(Y/N)”

INPUT ch$

IF ch$=”Y” OR ch$=”y” THEN

INPUT “New name=”;name$

INPUT “New roll number=”;roll

INPUT “New class=”;class

INPUT New date=”;date$

ENDIF

WRITE #2, name$, roll, class, date$

WEND

CLOSE #1, #2

KILL “student.dat”

NAME “temp.dat” AS “student.dat”

END

 

18) A sequential data file “information.dat” contains name, address and phone number of the students. WAP to enter a telephone number from the keyboard, match the telephone number with the telephone number stored in the file. If the telephone number matched then display “Record found” otherwise display “Record not found”

OPEN “information.dat” FOR INPUT AS#1

CLS

INPUT “Enter telephone number=”;tel$

WHILE NOT EOF(1)

INPUT #1, n$, a$, ph$

IF(ph$=tel$) THEN

PRINT “Record found”

ELSE

PRINT “Record not found”

ENDIF

PRINT “Name=”;n$

PRINT “Address=”;a$

PRINT “Telephone number”;ph$

WEND

CLOSE #!

END

 

19)    SLC 2069

Write a program to create a data file ‘teldir.dat’ to store Name, Address and Telephone number of employee according to the need of the user.

            OPEN “teldir.dat” FOR OUTPUT AS #1

            DO

            INPUT “Enter Name:”n$

            INPUT “Enter address:”;a$

            INPUT “Enter telephone no:”;t$

            WRITE #1, n$,a$,t$

            INPUT “Do you want to add more records (Y/N)?”;ch$

            LOOP WHILE UCASE$(ch$)= “Y”

            CLOSE #!

            END

 

20)    SLC 2070

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”, “Maths”, “Science”, “Nepali”

            WHILE NOT EOF(1)

            INPUT #1, n$, eng, math, sci, nep

            PRINT n$, eng, math, sci, nep

            WEND

            CLOSE #1

            END

21)    SLC 2067 Supp.

A sequential data file called “Marks.dat” contains Roll no, Name, English, Nepali, and Maths fields. Write a program to display all the contents of the data file.

            OPEN “marks.dat” FOR INPUT AS #1

            CLS

            PRINT “Roll no”,“Name”, “English”, “Maths”, “Science”, “Nepali”

            DO WHILE NOT EOF(1)

            INPUT #1, r, n$, eng, math, sci, nep

            PRINT r, n$, eng, math, sci, nep

            LOOP

            CLOSE #1

            END

 

22)    SLC 2068 Supp.

WAP to view those records from “employee.dat” sequential data file having employee’s name, department, appointment data and salary whose salary is more than Rs 5000.

            OPEN “employee.dat” FOR INPUT AS #2

            CLS

            WHILE NOT EOF(2)

            INPUT #2, n$,d$,a$,s

            IF s>=5000 THEN PRINT n$,d$,a$,s

            WEND

            CLOSE #2

            END

 

23)    SLC 2069 Supp.

A sequential data file “staff.dat” contains the name, address, post and salary of employees. Write a program to read and display all the records in the above data file.

OPEN “staff.dat” FOR INPUT AS #1

CLS

PRINT “Name”, “Address”, “Post”, “Salary”

DO WHILE NOT EOF(1)

INPUT #1, n$,a$,p$,s

PRINT n$,a$,p$,s

LOOP

CLOSE #1

END

 

24)    SLC 2071

A data file “salary.dat” contains the information of employee regarding their name, post and salary. Write a program to display all the information of employee whose salasy 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$,sa

IF sa>15000 AND sa<40000 THEN

PRINT “Name”;n$

PRINT “Post”;p$

PRINT “Salary”;sa

ENDIF

LOOP

CLOSE #1

END

25) SLC 2070 Supp.

      A sequential data file “record.dat” has records with field name, address, age and salary. Write a program to display only those records whose age is greater than 26.

OPEN "record.dat" FOR INPUT AS #1

PRINT "Name", "Address", "Age", "Salary"

DO WHILE NOT EOF(1)

INPUT #1, n$, a$,age, sal

IF age>26 THEN PRINT n$,a$,age,sal

LOOP

CLOSE #1

END

 

26) A sequential data file “Employee.rec” consists of numerous records of employees of a company on the following fields: employee’s name, post, salary and status (i.e. permanent or temporary) Write a program to read records of the “Employee.rec” file and display the records of permanent employees whose post is manager.

 OPEN “Employee.rec” FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

INPUT #1, N$, P$, S, S$

            IF UCASE$(P$)= “MANAGER” AND UCASE$(S$)= “PERMANENT” THEN PRINT N$, P$, S, S$

WEND

CLOSE #1

END

27) Data file named “RECORD.DAT” contains name, age and salary for ‘n’ number of persons. Write a program to input a name to search data from data file. If the data is not found, then display the message “Data not found in the list.”

 OPEN “RECORD.DAT” FOR INPUT AS #1

CLS

INPUT “Enter name to search data”; S$

FLAG=0

WHILE NOT EOF(1)

INPUT #1, N$, A, S

IF UCASE$(S$)=UCASE$(N$) THEN

PRINT N$, A, S

FLAG=1

END IF

WEND

IF FLAG=0 THEN PRINT “DATA NOT FOUND”

CLOSE #1

END

 28)    SEE 2072

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

 

29)    SEE 2073

Create a data file to store the records of few employees having Name, Address, Post, Gender and Salary fields.

OPEN “std.rec” FOR OUTPUT AS #1

DO

CLS

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

 

30) SEE 2073 Supp.

     A sequential data file called "ADDRESS.DAT" contains NAME, AGE, CITY and TELEPHONE fields. Write a program to display all the contents of the data file.

OPEN "ADDRESS.DAT" FOR INPUT AS #1

DO WHILE NOT EOF(1)

INPUT #1, n$,a,c$,t$

PRINT n$,a,c$,t$

LOOP

CLOSE #1

END

 

31. SEE 2074

Write a program to store Roll no., Name, Class and Address of any five students.

OPEN "Student.dat" FOR OUTPUT AS #1

FOR I = 1 TO 5

INPUT "Enter Roll No.", r

INPUT "Enter Name", n$

INPUT "Enter Class", c

INPUT "Enter Address", a$

WRITE #1, r, n$, c, a$

NEXT I

CLOSE #1

END

 

32. SEE 2075

     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 “SALARY.dat” FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

INPUT #1, A, B$, C$, D$, E

IF E > 40000 THEN PRINT A, B$, C$, D$, E

WEND

CLOSE #1

END

33. SEE 2075(state 2)

      Write a program to create a sequential data file “salary.data” to store programmer’s Name, salary and post according to the need of the user.

OPEN “SALARY.dat” FOR OUTPUT AS #1

DO

CLS

INPUT “Enter Name”; N$

INPUT “Enter salary”; S

INPUT “Enter Post”; P$

WRITE #1, N$, S, P$

INPUT “Do you want to continue(Y/N)”; CH$

LOOP WHILE UCASE$(CH$)=”Y”

CLOSE #1

END

 

34. SEE 2079

A sequential data file called "record.dat" has stored data under the field heading:  Roll no, name, gender, English, Nepali, Math's, and Computer. Write a program to display all the information of those students whose marks in English is more than 40. 

OPEN "record.dat" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, rn, n$, g$, eng, nep, math, comp
IF eng > 40 THEN PRINT rn, n$, g$, eng, nep, math, comp
LOOP
CLOSE #1
END

35) SEE 2078 Grade Promotion

Student name, class, section, and address are stored in a data file called "student.dat". Write a program to print all the records of students.

OPEN "student,dat" FOR INPUT AS #5

CLS

DO WHILE NOT EOF(5)

INPUT #5, name$,cl,s$,add$

PRINT name$,cl,s$,add$

LOOP

CLOSE #5

END

 

36) SEE 2078

Write a program to create a sequential data file “salary.dat” to store programmer’s name, salary and post according to the need of the user.      

OPEN “salary.dat” FOR OUTPUT AS #1

top:

INPUT “Enter programmers name”;n$

INPUT “Enter salary”;s

INPUT “Enter post”;p$

INPUT “Do you need more records”;ch$

IF UCASE$(ch$)=”Y” then GOTO top

CLOSE #1

END

 

37) A sequential data file "employee.dat" contains name, address, age and salary of employee. Write a program to display all the information whose address is "Kathmandu" and salary is greater than 50000.

OPEN "employee.dat" FOR INPUT AS #2
CLS
DO WHILE NOT EOF(2)
INPUT #1,name$, add$, age, sal
IF UCASE$(add$)="KATHMANDU" AND s > 50000 THEN
PRINT name$, add$, age, sal
ENDIF
WEND
CLOSE #1
END

 

38) SEE grade promotion 2079

Student name, class, section and address are stored in a data file called "student.dat". Write a program to print all the records of students.

OPEN "student.dat" FOR INPUT AS #1

CLS

DO WHILE NOT EOF(1)

INPUT #1, n$,c,s$,a$

PRINT n$,c,s$,a$

LOOP

CLOSE #1

END

 

39) Npabson SEE Pre-Qualifying exam-2080

A sequential data file, "record.dat" contains several records with data items name, address, age, and phone number. Write a program to display all the records of students whose age is greater than or equal to 18. 

Ans:
OPEN "record.dat" FOR INPUT AS #1
CLS
DO WHILE NOT EOF(1)
INPUT 31, n$,a$,age,ph
IF age>=18 THEN PRINT n$, a$, age, ph
LOOP
CLOSE #1
END

40. Pabson SEE pre-board examination 2080

A sequential data file "record.dat" contains the name, address, salary of employee, and display the records of those whose salary is more than 37000 and whose name ends with "DHA"   

CLS

OPEN "record.dat" for INPUT AS #1

DO WHILE NOT EOF(1)

INPUT #1, n$,a$,s

IF s>37000 AND RIGHT$(a$,3)="DHA" THEN

PRINT "Name:";n$

PRINT "Address: ";a$

PRINT "Salary:";s

ENDIF

LOOP

CLOSE #1

END                                                                                                                               

 You may also read:

File Handling in QBASIC

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages