FILE HANDLING IN QBASIC (EXERCISE 1)


 

#Programming#

#WRITE A PROGRAM TO CREATE A DATA FILE “AVN.DAT” AND STORE NAME, CLASS AND ADDRESS.

CLS

OPEN “AVN.DAT” FOR OUTPUT AS #1

INPUT “ENTER NAME”;N$

INPUT “ENTER CLASS”;C

INPUT “ENTER ADDRESS”;A$

WRITE #1, N$, C, A$

CLOSE #1

END

 

#WRITE A PROGRAM TO CREATE A SEQUENTIAL DATA FILE “BOOKS.AVN” TO STORE AUTHOR’S NAME, BOOK’S NAME AND PRICE OF THE BOOK.

CLS

OPEN “BOOKS.AVN” FOR OUTPUT AS #1

INPUT “ENTER AUTHOR’S NAME”;A$

INPUT “ENTER BOOK’S NAME”;B$

INPUT “ENTER PRICE OF THE BOOK”;P

WRITE #1, A$, B$, P

CLOSE #1

END

 

#WRITE A PROGRAM TO CREATE A DATA FILE TO STORE THE RECORDS OF FEW EMPLOYEES HAVING NAME, ADDRESS, POST, GENDER AND SALARY FIELDS.

CLS

OPEN “RECORDS.DAT” FOR OUTPUT AS #1

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 (Y/N)”;ANS$

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

CLOSE #1

END

 

#WRITE A PROGRAM TO CREATE A DATA FILE “INFO.DAT” AND STORE TEACHER’S NAME, ADDRESS AND PHONE NUMBER.

CLS

OPEN “INFO.DAT” FOR OUTPUT AS #1

INPUT “ENTER TEACHER’S NAME”;N$

 INPUT “ENTER ADDRESS”;A$

INPUT “ENTER PHONE NUMBER”;P#

WRITE #1, N$, A$, P#

CLOSE #1

END

 

#WRITE A PROGRAM TO CREATE A SEQUENTIAL DATA FILE “STD.DAT” TO STORE NAME AND MARKS OBTAINED IN ENGLISH, MATHS, AND SCIENCE FOR A FEW STUDENTS.

CLS

OPEN “STD.DAT” FOR OUTPUT AS #1

DO

INPUT “ENTER NAME”;N$

INPUT “ENTER MARK OBTAINED IN ENGLISH”;E

INPUT “ENTER MARK OBTAINED IN MATHS”;M

INPUT “ENTER MARK OBTAINED IN SCIENCE”;S

WRITE #1, N$,E,M,S

INPUT “DOYOU WANT TO CONTINUE (Y/N)”;ANS$

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

CLOSE #1

END

 

#WRITE A PROGRAM TO CREATE A SERIAL FILE HAVING LENGTH RECORDS OF NAME, DEPARTMENT AND TELEPHONE NUMBER.

CLS

INPUT “ENTER FILENAME”;N$

OPEN “N$” FOR OUTPUT AS #1

DO

INPUT “ENTER NAME”;N$

INPUT “ENTER DEPARTMENT”;D$

INPUT “ENTER TELEPHONE NUMBER”;T#

WRITE #1, N$,D$,T#

INPUT “DOYOU WANT TO CONTINUE (Y/N)”;ANS$

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

CLOSE #1

END

 

#WRITE A PROGRAM TO CREATE A SEQUENTIAL DATA FILE “HOTEL.DAT” TO STORE CUSTOMER’S NAME, ADDRESS AND PHONE NUMBER. PROGRAM SHOULD TERMINATE WITH USER CHOICE.

CLS

OPEN “HOTEL.DAT” FOR OUTPUT AS #1

DO

INPUT “ENTER CUSTOMER’S NAME”;N$

INPUT “ENTER ADDRESS”;A$

INPUT “ENTER PHONE NUMBER”;P#

WRITE #1, N$,A$,P#

INPUT “DOYOU WANT TO CONTINUE (Y/N)”;ANS$

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

CLOSE #1

END

 

#WRITE A SEQUENTIAL DATA FILE “CUSTOMER.INF” TO STORE CUSTOMER NAME, ADDRESS, OCCUPATION AND TELEPHONE NUMBER OF TWENTY CUSTOMERS.

CLS

OPEN “CUSTOMER.INF” FOR OUTPUT AS #1

FOR I=1 TO 20A

INPUT “ENTER NAME”;N$

INPUT “ENTER ADDRESS”;A$

INPUT “ENTER OCCUPATION”;O$

INPUT “ENTER TELEPHONE NUMBER”;T#

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

NEXT I

CLOSE #1

END

 

#WRITE A PROGRAM THAT ASKS A USER TO INPUT SYMBOLS NUMBER, NAME AND MARKS IN ANY THREE DIFFERENT SUBJECTS (MATHS, SCIENCE, COMPUTER) OF A STUDENT. THE PROGRAM STORES THE INFORMATION IN A “STUDENT.REC” DATA FILE. THE PROGRAM SHOULD ALLOW THE USER TO ENTER MORE RECORDS.

CLS

OPEN “STUDENT.REC” FOR OUTPUT AS #1

DO

INPUT “ENTER SYMBOL NUMBER”;S#

INPUT “ENTER NAME”;N$

INPUT “ENTER MARK IN MATHS”;M

INPUT “ENTER MARK IN SCIENCE”;S

INPUT “ENTER MARK IN COMPUTER”;C

WRITE #1, S#,N$,M,S,C

INPUT “DOYOU WANT TO CONTINUE (Y/N)”;ANS$

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

CLOSE #1

END 

 

Sujit Prasad Kushwaha

A Dedicated Blogger Sharing Insights and Making a Difference.

Post a Comment

The comment section is your chance to make your mark. Don't hold back - add to the discussion and let your personality shine through!

Previous Post Next Post