QBASIC FILE HANDLING PROGRAMS COMPUTER SCIENCE FOR SLC STUDENTS [COLLECTION]


[SPECIAL THANKS TO SARIKA SHRESTHA FOR SOLVING]

1.       Write a program to create a sequential data file “RESULT.DAT” to store name, address and marks obtained in 3 different subjects of students. [PABSON SEND UP 2066]
-          OPEN “RESULT.DAT” FOR OUTPUT AS #1
DO
CLS
INPUT “Enter name”; N$
INPUT “Enter address”; A$
INPUT “Enter marks in three different subjects”; M1, M2, M3
WRITE #1, N$, A$, M1, M2, M3
INPUT” Do you want to continue(Y/N)”;CH$
LOOP WHILE UCASE$(CH$)=”Y”
CLOSE #1
END

2.       Write a program to search and display only those record whose percentage is more than 60% from the data “RESULT.DAT” which contain Student’s Symbol number, Date of birth, Total Marks, Percentage and Division. [PABSON SEND UP 2067]
-          OPEN “RESULT.DAT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT #1, SN, D$, T, P, DA$
IF P>60 THEN PRINT SN, D$, T, P, DA$
WEND
CLOSE #1
END

3.       A data file name “STUDENT.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) [SLC SEND UP 2067]
-          OPEN “STUDENT.DAT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT #1, N$, P$, S
IF UCASE$(P$)=”MANAGER” THEN
C=C+1
END IF
WEND
PRINT “The total numbers of managers are”; C
CLOSE #1
END

4.       WAP to create sequential file “Person.DAT” containing information like Name, age, DOB and sex. Add records in this data file as per the users choice. [PABSON SLC 2064]
-          OPEN “PERSON.DAT” FOR OUTPUT AS #1
DO
CLS
INPUT” Enter name”; N$
 INPUT” Enter age”; A$
INPUT” Enter date of birth”; D$
INPUT” Enter Sex”; S$
WRITE #1, N$, A$, D$, S$
INPUT “Do you want to continue(Y/N)”; CH$
LOOP WHILE UCASE$(CH$)=”Y”
CLOSE #1
END

5.       Write a program to store SIDNO, name, address and Telephone number of five students and display the records on monitor in sequential data file “STDINFO”. [MAAF SLC SEND UP 2068]
-          OPEN “ STDINFO.DAT” FOR OUTPUT AS #1
DO
CLS
INPUT “Enter SID NO. “; N
INPUT “Enter name”; N$
INPUT “Enter address”; A$
INPUT “Enter telephone number”; T#
WRITE #1, N, N$, A$, T#
INPUT “Do you want to continue(Y/N)”; CH$
LOOP WHILE UCASE$(CH$)=”Y”
CLOSE #1
END

6.       Write a program to create a data file “SLC.dat” to store Name,Class,and marks in three subjects of 15 students. [PABSON SLC SEND UP 2068]
-          OPEN “SLC.DAT” FOR OUTPUT AS #1
FOR I = 1 TO 15
CLS
INPUT “Enter name”; N$
INPUT “Enter class”; C
INPUT “Enter marks in three different subjects”; M1, M2, M3
WRITE #1, N$,C,M1,M2,M3
NEXT I
CLOSE #1
END

7.       Write a program to create a data file “result.dat” to store name, address and obt. Marks in three different subjects of students. [SLC SEND UP 2069]
-          OPEN “RESULT.DAT” FOR OUTPUT AS #1
DO
CLS
INPUT “Enter name”; N$
INPUT “Enter address”; A$
INPUT “Enter marks in three different subjects”; M1, M2, M3
WRITE #1, N$, A$, M1, M2, M3
INPUT “Do you want to continue(Y/N)”; CH$
LOOP WHILE UCASE$(CH$)=”Y”
CLOSE #1
END

8.       Write a program to open a data file “STUDENT.DAT”that contains Name, Address, Telephone number and Parent’s Name of some students. Now display all those records whose address is “LALITPUR”. [JM SECOND TERM 2068]
-          OPEN “STUDENT.DAT” FOR INPUT AS #1
CLS
WHILE OT EOF(1)
INPUT #1, N$, A$, T#, PN$
IF UCASE$(A$)=”LALITPUR” THEN PRINT N$, A$, T#, PN$
WEND
CLOSE #1
END

9.       A data file”STUDENT.DAT” has several records in it.Write a program to read existing record from the file and display the total number or records.
-          OPEN “STUDENT.DAT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
LINE INPUT #1, R$
C=C+1
WEND
PRINT “Total number of records=”; C
CLOSE #1
END

10.    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
DO
CLS
INPUT “Enter item name”; N$
INPUT “Enter quantity”; Q
INPUT “Enter rate”; R
T= Q*R
WRITE #1, N$, Q, R
INPUT “Do you want to continue(Y/N)”;CH$
LOOP WHILE UCASE$(CH$)=”Y”
CLOSE #1
END

11.    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
CLS
INPUT “Enter your name”; N$
INPUT “Enter marks in three different subjects”; M1, M2, M3
T=M1+M2+M3
P= T/3
WRITE #1, N$, M1, M2, M3, T, P
NEXT I
CLOSE #1
END

12.    A sequential data file’post.dat’ has few records related to name,address,salary and DOB (mm/dd/yyyy).WAP to:
                                             i.            Display all the records as well as count and display he total number of records also.
                                            ii.            Display the records whose address begins with ‘S’ or ‘D’

-          i)
-          OPEN “POST.DAT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT #1, N$, A$, S, D$
PRINT N$, A$, S, D$
C=C+1
WEND
PRINT “Total number of records=”; C
CLOSE #1
END
-           
-          ii)
-          OPEN “POST.DAT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT #1, N$, A$, S, D$
B$=LEFT$(A$,1)
IF UCASE$(B$)=”S” OR UCASE$(B$)=”D” THEN PRINT N$, A$, S, D$
WEND
CLOSE #1
END


Comments

Popular posts from this blog

PROGRAM TO FIND SQUARE, CUBE, SQUARE ROOT AND CUBE ROOT OF GIVEN NUMBER

PROGRAM TO DISPLAY SUM, PRODUCT, DIFFERENCE AND PRODUCT OF TWO / THREE NUMBERS

PALINDROME AND ARMSTRONG PROGRAMS