Wednesday, February 17, 2021

QBASIC PROJECT : STUDENT INFORMATION SYSTEM - SEE COMPUTER SCIENCE 2077

 QBASIC PROJECT : STUDENT INFORMATION SYSTEM

SEE COMPUTER SCIENCE 2077



DECLARE SUB ADD()

DECLARE SUB DIS()

DECLARE SUB SER()

DECLARE SUB DEL()

DECLARE SUB UPD()

TOP:

CLS

LOCATE 3, 15:

PRINT STRING$(45, "*")

LOCATE 17, 15:

PRINT STRING$(45, "*")

FOR I = 3 TO 17

    LOCATE I, 13: PRINT "*"

    LOCATE I, 59: PRINT "*"

NEXT I

LOCATE 25, 50:

PRINT "DEVELOPED BY : DEEPAK SHRESTHA"

LOCATE 5, 30:

PRINT "**WELCOME**"

LOCATE 6, 25:

PRINT "STUDENT INFORMATION SYSTEM"

LOCATE 7, 30:

PRINT "MAIN MENU"

LOCATE 8, 30:

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

LOCATE 9, 25:

PRINT "1. ADD RECORDS"

LOCATE 10, 25:

PRINT "2. DISPLAY RECORDS"

LOCATE 11, 25:

PRINT "3. SEARCH RECORDS"

LOCATE 12, 25:

PRINT "4. DELETE RECORDS"

LOCATE 13, 25:

PRINT "5. UPDATE RECORDS"

LOCATE 14, 25:

INPUT "ENTER YOUR CHOICE (1-5)"; C

SELECT CASE C

    CASE 1

        CALL ADD

    CASE 2

        CALL DIS

    CASE 3

        CALL SER

    CASE 4

        CALL DEL

    CASE 5

        CALL UPD

    CASE ELSE


        LOCATE 20, 25: PRINT "PLEASE ENTER CORRECT NUMBER"

END SELECT

LOCATE 22, 20:

INPUT "DO U WANT TO GO TO MAIN MENU (Y/N)"; ANS$

IF UCASE$(ANS$) = "Y" THEN GOTO TOP

END


SUB ADD ()

OPEN "STD.DAT" FOR APPEND AS #1

DO

    CLS

    INPUT "ENTER ROLL NUMBER"; R

    INPUT "ENTER NAME"; N$

    INPUT "ENTER ADDRESS"; A$

    INPUT "ENTER TELEPHONE NUMBER"; T#

    WRITE #1, R, N$, A$, T#

    INPUT "DO YOU WANT TO CONTINUE(Y/N)"; CH$

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

CLOSE #1


END SUB


SUB DIS ()

OPEN "STD.DAT" FOR INPUT AS #1

CLS

PRINT "ROLL NUMBER", "NAME", "ADDRESS", "TELEPHONE"

WHILE NOT EOF(1)

    INPUT #1, R, N$, A$, T#

    PRINT R, N$, A$, T#

WEND

CLOSE #1


END SUB


SUB SER ()

OPEN "STD.DAT" FOR INPUT AS #1

CLS

INPUT "ENTER ROLL NUMBER TO SEARCH DATA"; SR

FLAG = 0

PRINT "ROLL NUMBER", "NAME", "ADDRESS", "TELEPHONE"

WHILE NOT EOF(1)

    INPUT #1, R, N$, A$, T#

    IF SR = R THEN

        PRINT R, N$, A$, T#

        FLAG = 1

    END IF

WEND

IF FLAG = 0 THEN PRINT "RECORD NOT FOUND"

CLOSE #1


END SUB


SUB DEL ()

OPEN "STD.DAT" FOR INPUT AS #1

OPEN "TEMP.DAT" FOR OUTPUT AS #2

CLS

INPUT "ENTER ROLL NUMBER TO DELETE DATA"; DR

FLAG = 0

WHILE NOT EOF(1)

    INPUT #1, R, N$, A$, T#

    IF DR = R THEN

        FLAG = 1

    ELSE

        WRITE #2, R, N$, A$, T#


    END IF

WEND

CLOSE

KILL "STD.DAT"

NAME "TEMP.DAT" AS "STD.DAT"

IF FLAG = 0 THEN

    PRINT "DATA NOT FOUND"

ELSE

    PRINT "DATA DELETED SUCCESSFULLY"

END IF


END SUB


SUB UPD ()

OPEN "STD.DAT" FOR INPUT AS #1

OPEN "TEMP.DAT" FOR OUTPUT AS #2

CLS

INPUT "ENTER ROLL NUMBER TO UPDATE DATA"; UR

FLAG = 0

WHILE NOT EOF(1)

    INPUT #1, R, N$, A$, T#

    IF UR <> R THEN

        WRITE #2, R, N$, A$, T#

    ELSE

        INPUT "ENTER ROLL NUMBER"; ER

        INPUT "ENTER NAME"; EN$

        INPUT "ENTER ADDRESS"; EA$

        INPUT "ENTER TELEPHONE NUMBER"; ET#

        WRITE #2, ER, EN$, EA$, ET#

        FLAG = 1

    END IF

WEND

CLOSE

KILL "STD.DAT"

NAME "TEMP.DAT" AS "STD.DAT"

IF FLAG = 0 THEN

    PRINT "DATA NOT FOUND"

ELSE

    PRINT "DATA DELETED SUCCESSFULLY"

END IF


END SUB




Saturday, February 13, 2021

QBASIC FILE HANDLING PROGRAMS SET QUESTIONS COLLECTION - SEE COMPUTER SCIENCE 2077

 QBASIC FILE HANDLING PROGRAMS SET QUESTIONS COLLECTION

SEE COMPUTER SCIENCE 2077


SET 1

1.     Write a program to create a sequential  data file “Employee.dat” to store employees’ name, address, age and gender. [SLC 2066 R]

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 S]

3.     A sequential data file “EMP.DAT” contains name, post and salary fields of information about employees. Write a program to display all information of employees along with tax amount also.(Tax is 15% of salary) [SLC 2067 R]

4.     A sequential data file called “student.dat” contains some records under the fields Name, English, Nepali and computer. Write a program to add some more records in the same sequential data file. [SLC 2068 R]

5.     Write a program 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. [SLC 2068 S]

6.     A sequential data file “Record.dat” has records with field name, addres, age and salary. Write a program to display only those records whose age is greater than 26. [SLC 2070 S]

7.     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 salary is greater than 15000 and less than 40000. [SLC 2071 R]

8.     A sequential data file called “Marks.dat” has stored data under the field heading Roll No, Name, English, Nepali and maths. Write a program to display all the information of those students whose marks in Nepali is more than 50. [SLC 2071 S]

9.     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. [SEE 2072]

10.  Write a program to store Roll no., Name, Class and Address of any five students. [SEE 2074]

 

 

 

SET 2

1.     Create a sequential data file “std.dat” to store name and marks obtained in English, Math and Science subjects for a few students. [SEE MODEL 2065]

2.     Write a program to store records regarding the information of Book Number, Book’s name and Writer’s name in a sequential data file called “Library.dat”. [SLC 2065 R]

3.     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 data file. [SLC 2065 S], [SLC 2067 S]

4.     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. [SLC 2069 R]

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 file. [SLC 2069 S]

6.     A sequential data file called “Marks.dat” contains name, english, nepali, maths and science fields. Write a program to display all the contents of that data file. [SLC 2070 R]

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

8.     A data file "STAFF. dat" has stored records of few employees with EmPID, First name, Lastname, post and salary. Write a program to display all the records of the employees whose salary is more than  40,000. [SEE 2075]

9.     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. [SEE 2075 S2]

10.  A Sequential data file called "SEE.DAT" has stored data under the field heading Symbol No., Name, English, Nepali, Maths and Computer. Write a program to display all the information of those students whose marks in Computer is more than 80. [SEE 2074 S]

 

 

 

 

 

SET 3

1.      Create a sequential data file ’Price.dat’ to store item name, quantity and Rate also calculate total amount(total=Quantity X Rate).Program should terminate according to the user’s choice.

2.      Create a sequential data file’post.dat’ to store name and marks of any three subjects also calculate total and percentages only for 15 students.

3.      A sequential data file “Address.inf” contains serial no, name, address, telephone and email_id.WAP to record as many records as the user wants. The serial number should be generated automatically like 5001,5003,5005.

4.      A sequential data file “STD.TXT” contains name and marks in three different subjects of some students. Write a program to display only fail student’s records assuming pass marks 40.

5.      Write a program which reads records from the file ”Result.DAT” having the fields name, and marks of three different subjects and display only those records whose percentage is greater than 60 and less than 80. Also count the total number of records presenting in that data files.

6.      Write a program to read all the records from the data file “STUDENT.TXT” and display all the records where the fields name are unknown.

7.      A data file "pabson.txt" contains the records composed of the fields like school, principal, address, contact. Write a program in Qbasic to display records of the schools located in either Kathmandu or Palpa

8.      A data file “INFO.DAT” has numerous records in it with name, address age, and telephone numbers in it. Write a program to read all the records and print those with address “NEPAL” and age >15

9.      Write a program in QBASIC to open a sequential data file “EMP.DAT”, which contains employees records: Name, address and phone number and display all the records as well as total number of records stored in the file.

10.  A sequential data file “SALARY.DAT” contains the information, Employee-Code, Employee-Name, Post, Basic-Salary. Write a program to display those records whose Basic-salary is between 10000 to 15000 and Post is ‘OFFICER’.

 

 

 

 

SET 4

1.     A data file name “EMP.DAT”, contains number of records having fields name, post and salary. Write a program to count total number of “Manager” in the data file. (hint: Manager is a post)

2.     Write a program that reads the ”INFO.DAT” file that has several record such as name, address, gender, post, and salary .The program display those record whose sex is male and salary more than 10,000 and also the program counts the total number of records in that file.

3.     A sequential data file’post.dat’ has few records related to name, address, salary.WAP to display the records whose address begins with ‘S’ or ‘D’

4.     Write a program to open a data file “record.dat” that contains name, address, date of birth, email and telephone number of some employees. Now display all those records whose date of birth is in current month.

5.     A sequential data file “Record.dat” has few records related to name, address, post and DOB(mm/dd/yyyy). WAP to display the records of all those who were born between 1971 to 1999.

6.     Write a Qbasic program that read the "EMP.DAT" file with Name, Address, Post and Salary columns from E: drive that has 500 records of employees and displays only its last 50 records.

7.     A sequential data file has 100 records having field name, class and roll number. Write a program to display from 50th to 60th records.

8.     Write a program to display the first 10 records from a file named “resource.dat” having fields name, phone and email.

9.     A data file named “EMP.DAT” contains some records with the fields Code, Name, Post and Salary. Write a program to print odd position records of the data file.

10.  A sequential data file named “abc.dat” has several records having fields name, roll and class. Write a program to copy all the records of class 10 into a newly created file new.dat.

 

 

 

SET 5

11.   A 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 a data file. If the data is not found, then display the message “Data not found in the list”.

12.   A sequential data file 'Student.dat' contains registration number, student name, address and date of birth of some students. Write a program that asks a user to input a registration number and displays the record of the particular registration if present.

13.   Delete some records from “neps.dat” file where computer ask user to enter the record, which is to be deleted. (Fields are name, address, and telephone number)

14.   A sequential data file “RECORD.DAT” contains different records under fields: name rollno., name, address and percentage. Write a program to edit a record and display both edited and unedited records on the screen to compare them side by side.

15.   A sequential data file “marks.dat” contains information such as student’s name, marks obtained in math, science and computer. Write a program that increase the marks of computer by 10 of those student who secured less than 40

 


QBASIC FILE HANDLING PROGRAMS - ALL IN ONE COLLECTION - COMPUTER SCIENCE 2077

 QBASIC FILE HANDLING PROGRAMS - 

ALL IN ONE COLLECTION - 

COMPUTER SCIENCE 2077

146.Write a program to store Roll no., Name, Class and Address of any five students. [SEE 2074]

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

147.A sequential data file called “student.dat” contains same records under the field’s name, english, nepali and computer. Write a program to add some more records in the same sequential data file. [SLC 2068]

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”; CH$

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

CLOSE #1

END

148.A sequential data file  “RECORD.DAT”contains records of Name, Address and Salary of employees. WAP to add some more records in the data file “RECORD.DAT”. Program should terminate with user choice.

OPEN “RECORD.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”; CH$

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

CLOSE #1

END

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

OPEN “std.rec” FOR OUTPUT AS #1

TOP:

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$

IF UCASE$(CH$)=”Y” THEN GOTO TOP

CLOSE #1

END

150.Create a sequential data file ’Price.dat’ to store item name, quantity and Rate also calculate total amount(total=Quantity X Rate).Program should terminate according to the user’s choice. 

OPEN “price.dat” FOR OUTPUT AS #1

TOP:

CLS

INPUT “Enter Item Name”; N$

INPUT “Enter Quantity”; Q

INPUT “Enter Rate”; R

T = Q * R

WRITE #1, N$, Q, R, T

INPUT “Do you want to continue”; CH$

IF CH$=”Y” OR CH$ = “y” THEN GOTO TOP

CLOSE #1

END

151.Create a sequential data file’post.dat’ to store name and marks of any three subjects also calculate total and percentages only for 15 students.

OPEN "post.dat" FOR OUTPUT AS #1

FOR I = 1 TO 15
INPUT "Enter Name"; n$
INPUT "Enter marks in any three subjects”; A, B, C
T = A + B + C

P = T / 3

WRITE #1, n$, A, B, C, T, P

NEXT I
CLOSE #1
END

152.Store SIDNO, name, address and Telephone number of five students and display the records on monitor in sequential data file “STDINFO”

OPEN "STDINFO.DAT" FOR OUTPUT AS #1

FOR I = 1 TO 5

        INPUT "ENTER NAME"; N$

    INPUT "ENTER ADDRESS"; A$

    INPUT "ENTER TELEPHONE"; T#

    WRITE #1, N$, A$, T#

NEXT I

CLOSE #1

OPEN "STDINFO.DAT" FOR INPUT AS #1

CLS

FOR I = 1 TO 5

    INPUT #1, N$, A$, T#

    PRINT N$, A$, T#

NEXT I

CLOSE #1

END

153.A sequential data file “Address.inf” contains serial no, name, address, telephone and email_id.WAP to record as many records as the user wants. The serial number should be generated automatically like 5001,5003,5005.

OPEN " Address.inf " FOR OUTPUT AS #1

DO

CLS

C = 5001

INPUT “ENTER NAME”; N$

INPUT “ENTER ADDRESS”; A$

INPUT “ENTER TELEPHONE”; T#

INPUT “ENTER EMAIL”; E$

    WRITE #1, C, N$, A$, T$, E$

C = C + 2

INPUT “DO YOU WANT TO CONTINUE (Y / N)”; CH$

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

CLOSE #1

END

154.A Sequential data file called "SEE.DAT" has stored data under the field heading Symbol No., Name, English, Nepali, and Computer. Write a program to display all the information of those students whose marks in Computer is more than 80.

OPEN "SEE.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

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

WEND

CLOSE #1

END

155.A sequential data file “STD.TXT” contains name and marks in three different subjects of some students. Write a program to display only fail student’s records assuming pass marks 40.

OPEN "STD.TXT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

    IF C < 40 AND D <40 AND E <40 THEN PRINT B$, C, D, E

WEND

CLOSE #1

END

156.Write a program which reads records from the file ”Result.DAT” having the fields name, and marks of three different subjects and display only those records whose percentage is greater than 60 and less than 80. Also count the total number of records presenting in that data files.

OPEN "STD.TXT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

A=A+1

T=C+D+E

P=T/3

    IF P > 60 AND P < 80 THEN  PRINT B$, C, D, E

WEND

PRINT “TOTAL NO. OF RECORDS=”; A

CLOSE #1

END

157.Write a program to read all the records from the data file “STUDENT.TXT” and display all the records where the fields name are unknown.

 

OPEN "STUDENT.TXT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

   LINE INPUT #1, A$

    PRINT A$

WEND

CLOSE #1

END

 

158.A data file "pabson.txt" contains the records composed of the fields like school, principal, address, contact. Write a program in Qbasic to display records of the schools located in either Kathmandu or Palpa

OPEN "PABSON.TXT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

    IF UCASE$(C$) = “KATHMANDU” OR UCASE$(C$) = “PALPA” THEN PRINT A$, B$, C$, D

WEND

CLOSE #1

END

159.A data file “INFO.DAT” has numerous records in it with name, address age, and telephone numbers in it. Write a program to read all the records and print those with address “NEPAL” and age >15

OPEN "INFO.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

    IF UCASE$(B$) = “NEPAL” AND C >15 THEN PRINT A$, B$, C, D

WEND

CLOSE #1

END

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

OPEN "ADDRESS.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

    PRINT A$, B, C$, D

WEND

CLOSE #1

END

 

161.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

WHILE NOT EOF (1)

  INPUT #1, A$, B$, C

D = D + 1

WEND

PRINT “TOTAL NUMBER OF RECORDS=”; D

CLOSE #1

END

162.Write a program in QBASIC to open a sequential data file “EMP.DAT”, which contains employees records: Name, address and phone number and display all the records as well as total number of records stored in the file. 

OPEN "LIB.TXT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

  INPUT #1, A$, B$, C

PRINT A$, B$, C

D = D + 1

WEND

PRINT “TOTAL NUMBER OF RECORDS=”; D

CLOSE #1

END


 

 

164.A sequential data file “SALARY.DAT” contains the information, Employee-Code, Employee-Name, Post, Basic-Salary. Write a program to display those records whose Basic-salary is between 10000 to 15000 and Post is ‘OFFICER’.

OPEN "SALARY.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

    IF UCASE$(P$) = “OFFICER” AND S >= 10000 AND S>= 15000 THEN PRINT A$, B$, C, D

WEND

CLOSE #1

END

165.A data file name “EMP.DAT”, contains number of records having fields name, post and salary. Write a program to count total number of “Manager” in the data file. (hint: Manager is a post)

OPEN "EMP.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

  INPUT #1, N$, P$, S

    IF UCASE$(P$) = “MANAGER” THEN PRINT C = C + 1

WEND

PRINT “TOTAL NO.OF MANAGERS ARE”; C

CLOSE #1

END

166.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

WHILE NOT EOF (1)

  INPUT #1, N$, P$, S

    T = 15 / 100 * S

PRINT N$, P$, S, T

WEND

CLOSE #1

END

167.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 salary is greater than 15000 and less than 40000.

OPEN "EMP.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

  INPUT #1, N$, P$, S

    IF S >= 15000 AND S <= 40000 THEN PRINT N$, P$, S

WEND

CLOSE #1

END

168.Write a program that reads the ”INFO.DAT” file that has several record such as name, address, gender, post, and salary .The program display those record whose sex is male and salary more than 10,000 and also the program counts the total number of records in that file.

OPEN "INFO.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

C = C + 1   

IF UCASE$(G$)=”M” AND S >= 10000 THEN PRINT N$, A$, G$, P$, S

WEND

PRINT “TOTAL NUMBER OF RECORDS=”; C

CLOSE #1

END

169.A sequential data file’post.dat’ has few records related to name, address, salary.WAP to display the records whose address begins with ‘S’ or ‘D’

OPEN "POST.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

  INPUT #1, N$, P$, S

A$ = UCASE$(LEFT$(N$,1))   

IF A$ = “S” OR A$ = “D” THEN PRINT N$, P$, S

WEND

CLOSE #1

END

 

170.Write a program to open a data file “record.dat” that contains name, address, date of birth, email and telephone number of some employees. Now display all those records whose date of birth is in current month.

 

OPEN "birth.dat" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

    INPUT #1, n$, d$, a$

    b$ = LEFT$(DATE$, 2)

    c = VAL(b$)

    e$ = LEFT$(d$, 2)

    f = VAL(e$)

    IF c = f THEN PRINT n$, d$, a$

WEND

CLOSE #1

END

 

171.A sequential data file “Record.dat” has few records related to name, address, post and DOB(mm/dd/yyyy). WAP to display the records of all those who were born between 1971 to 1999.

 

OPEN "RECORD.dat" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

    d$ = RIGHT$(d$, 4)

    c = VAL(b$)

        IF c >= 1971 and c<=1999 THEN PRINT n$, d$, a$

WEND

CLOSE #1

END

 

 

 

172.Write a Qbasic program that read the "EMP.DAT" file with Name, Address, Post and Salary columns from E: drive that has 500 records of employees and displays only its last 50 records.

OPEN "E:\EMP.DAT" FOR INPUT AS #1

CLS

FOR i = 1 TO 500

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

    IF i >= 450 AND i <= 500 THEN PRINT n$, a$, p$, s

NEXT i

CLOSE #1

END

173.A sequential data file has 100 records having field name, class and roll number. Write a program to display from 50th to 60th records.

 

OPEN "ABC.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

  INPUT #1, N$, C, R

D = D + 1   

IF D >= 50 AND D <= 60 THEN PRINT N$, C, R

WEND

CLOSE #1

END

174.Write a program to display the first 10 records from a file named “resource.dat” having fields name, phone and email.

 

OPEN "RESOURCE.DAT" FOR INPUT AS #1

CLS

FOR I = 1 TO 10

  INPUT #1, N$, C, R

PRINT N$, C, R

NEXT I

CLOSE #1

END

 

175.A data file named “EMP.DAT” contains some records with the fields Code, Name, Post and Salary. Write a program to print odd position records of the data file.

OPEN "EMP.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF (1)

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

D = D + 1   

IF MOD 2 = 1 THEN PRINT C, N$, P$, S

WEND

CLOSE #1

END

176.A sequential data file named “abc.dat” has several records having fields name, roll and class. Write a program to copy all the records of class 10 into a newly created file new.dat.

 

OPEN "ABC.DAT" FOR INPUT AS #1

OPEN "NEW.DAT" FOR OUTPUT AS #1

CLS

WHILE NOT EOF (1)

  INPUT #1, N$, R, C

IF C = 10 THEN WRITE #2, N$, R, C   

WEND

CLOSE #1, #2

END

 

 

177.A 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 a 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 be searched”; 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

178.A sequential data file 'Student.dat' contains registration number, student name, address and date of birth of some students. Write a program that asks a user to input a registration number and displays the record of the particular registration if present.

OPEN “STUDENT.DAT” FOR INPUT AS #1

CLS

INPUT “Enter registration no. to be searched”; S

FLAG=0

WHILE NOT EOF(1)

INPUT #1, R, N$, A$, D$

IF S = R THEN

PRINT R, N$, A$, D$

FLAG=1

END IF

WEND

IF FLAG=0 THEN PRINT “Data not found”

CLOSE #1

END

179.WAP that asks a post of the employee and displays his/her records from the sequential data file “XYZ.REC” having fields Name, Post, Dept and Salary.

OPEN “XYZ.REC” FOR INPUT AS #1

CLS

INPUT “Enter post to be searched”; S$

FLAG=0

WHILE NOT EOF(1)

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

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

PRINT N$, P$, D$, S

FLAG=1

END IF

WEND

IF FLAG=0 THEN PRINT “Data not found”

CLOSE #1

END

 

 

 

180.Delete some records from “neps.dat” file where computer ask user to enter the record, which is to be deleted. (Fields are name, address, and telephone number)

 

OPEN “NEPS.DAT” FOR INPUT AS #1

OPEN “TEMP.DAT” FOR OUTPUT AS #1

CLS

INPUT “Enter name which is to be deleted”; D$

WHILE NOT EOF(1)

INPUT #1, N$, A$, T#

IF UCASE$(D$)<>UCASE$(N$) THEN

WRITE #2, N$, A$, T#

ELSE

PRINT “Deleted data=”; N$, A$, T#

END IF

WEND

CLOSE #1, #2

 KILL “NEPS.DAT”

NAME “TEMP.DAT” AS “NEPS.DAT”

END

----------------------------------------------------------------------------

182.A sequential data file “marks.dat” contains information such as student’s name, marks obtained in math, science and computer. Write a program that increase the marks of computer by 10 of those student who secured less than 40

OPEN "D:\PATIENT.DAT" FOR INPUT AS #1

OPEN "d:\TEMP.DAT" FOR OUTPUT AS #2

CLS

FLAG = 0

WHILE NOT EOF(1)

    INPUT #1, N$, A, B, C

    IF C > 40 THEN

        WRITE #2, N$, A, B, C

    ELSE

        C = C + 10

        WRITE #2, N$, A, B, C

        FLAG = 1

    END IF

WEND

IF FLAG = 0 THEN

    PRINT "DATA NOT FOUND"

ELSE

    PRINT "DATA EDITED"

END IF

CLOSE

KILL "D:\PATIENT.DAT"

NAME "D:\TEMP.DAT" AS "D:\PATIENT.DAT"

END

181.A sequential data file “RECORD.DAT” contains different records under fields: name rollno., name, address and percentage. Write a program to edit a record and display both edited and unedited records on the screen to compare them side by side.

OPEN "D:\RECORD" FOR INPUT AS #1
OPEN "d:\TEMP.DAT" FOR OUTPUT AS #2
CLS
INPUT "ENTER ROLL NUMBER TO EDIT DATA"; E
FLAG = 0
WHILE NOT EOF(1)
INPUT #1, R, N$, A$, P
IF E <> R THEN
WRITE #2, R, N$, A$, P
ELSE
INPUT "ENTER ROLL NUMBER"; ER
INPUT "ENTER NAME"; EN$
INPUT "ENTER ADDRESS"; EA$
INPUT "ENTER PERCENTAGE"; EP
WRITE #2, ER, EN$, EA$, EP
FLAG = 1
END IF
WEND
IF FLAG = 0 THEN
PRINT "DATA NOT FOUND"
ELSE
PRINT "NON EDITED DATA"
PRINT "ROLL NUMBER= "; R
PRINT "NAME= "; N$
PRINT "ADDRESS= "; A$
PRINT "PERCENTAGE= "; P
PRINT "---------------"
PRINT "EDITED DATA"
PRINT "ROLL NUMBER: "; ER
PRINT "NAME: "; EN$
PRINT "ADDRESS: "; EA$
PRINT "PERCENTAGE: "; EP
END IF
CLOSE
KILL "D:\SALARY.DAT"
NAME "D:\TEMP.DAT" AS "D:\SALARY.DAT"
END