Friday, February 12, 2021

QBASIC FILE HANDLING QUESTIONS COLLECTION 2077 - PART II

QBASIC FILE HANDLING QUESTIONS COLLECTION 2077 - PART II 


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 sequential  data file “Employee.dat” to store employees’ name, address, age and gender. [SLC 2066 R]

5.      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]

6.      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]

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

8.      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]

9.      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]

10.   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]

 

11.   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]

12.   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]

13.   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]

14.   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]

15.   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]

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

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

18.   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]

19.   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]

20.   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]

 

 


Wednesday, February 10, 2021

QBASIC FILE HANDLING PROGRAMS - PART I [SEE COMPUTER SCIENCE 2077]

 

QBASIC FILE HANDLING PROGRAMS - PART I

 [SEE COMPUTER SCIENCE 2077]


1. WAP to store name, post, address and salary for five employees.

 

OPEN "SAL.DAT" FOR OUTPUT AS #1

FOR I = 1 TO 5

CLS

INPUT "Enter name “; N$

INPUT “Enter post”; P$

INPUT "Enter address"; A$

INPUT “Enter salary”; S

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

NEXT I

CLOSE #1

END

 

2. WAP to store name, post, address and salary. The program should terminate according to user’s choice.

 

OPEN "SAL.DAT" FOR OUTPUT AS #1

DO

CLS

INPUT "Enter name "; N$

INPUT “Enter post”; P$

INPUT "Enter address"; A$

INPUT “Enter salary”; S

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

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

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

CLOSE #1

END

 

3. WAP to display all the records from the data file "SAL.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

PRINT N$, P$, A$, S

WEND

CLOSE #1

END

 

4. WAP to display all information whose salary is greater than 15,000 and less than 40,000 from the data file "SAL.DAT".

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

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

WEND

CLOSE #1

END

 

5. WAP to count and display total number of records from the data file "SAL.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

C=C+1

WEND

PRINT " Total number of records"; C

CLOSE #1

END

 

6. Wap to display all records as well as total number of records from the data file "SAL.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

PRINT N$, P $, A$, S

C=C+1

WEND

PRINT " Total number of records"; C

CLOSE #1

END

 

7. Wap to display all records whose post is officer from the data file "SAT.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

IF UCASE$(P$) = "OFFICER" THEN PRINT N$,P$,A$,S

WEND

CLOSE #1

END

8. Wap to display all the records whose salary is between 10000 to 15000 and post is officer from the data file "SAT.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

IF S>10000 AND S<15000 AND  UCASE$(P$)="OFFICER" THEN PRINT N$,P$,A$,S

WEND

CLOSE #1

END

 

9. WAP to count total number of managers from the data file "SAL.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

IF UCASE$(P$)="MANAGER" THEN C=C+1

WEND

PRINT " Total number of managers = "; C

CLOSE #1

END

 

10. WAP to display all information along with tax from the data file "SAT.DAT" (15% of salary)

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

T=15/100 *S

PRINT N$,P$,A$,S,T

WEND

CLOSE #1

END

 

11. WAP to display all records whose address is Kathmandu or Palpa from "SAL.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

IF UCASE$(A$) = "PALPA" OR UCASE$(A$)= "KATHMANDU" THEN PRINT N$,P$,A$,S

WEND

CLOSE #1

END

 

12.WAP to display all records whose address is Bhaktapur and salary is above 15000 from the data file "SAT.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

IF UCASE$(A$) = "BHAKTAPUR" AND S>15000 THEN PRINT N$,P$,A$,S

WEND

CLOSE #1

END

 

13. WAP to display all the records whose address begins with the letter S or D from the data file "SAL.DAT"

 

OPEN "SAL.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

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

IF UCASE$(LEFT$(A$,1))= "S" OR UCASE$(LEFT$(A$,1)) = "D" THEN PRINT N$, P$, A$, S

WEND

CLOSE #1

END

 

14. WAP to store name, class and marks in three subject for N number of records.

 

OPEN "RESULT.DAT" FOR OUTPUT AS #1

INPUT "Enter how many records"; N

FOR I = 1 to N

CLS

INPUT " Enter name "; N$

INPUT “Enter class”; C

INPUT "Enter marks in 3 subjects"; X,Y,Z

WRITE #1, N$,C,X,Y,Z

NEXT I

CLOSE #1

END

 

15. WAP to store a name, class and marks in 3 subjects in the data file "RESULT.DAT" only whose class is 10.

 

OPEN "RESULT.DAT" FOR OUTPUT AS #1

DO

CLS

INPUT " Enter name "; N$

INPUT “Enter class”; C

INPUT " Enter marks in 3 subjects"; X, Y, Z

IF C=10 THEN WRITE #1, N$,C,X,Y,Z

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

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

CLOSE #1

END

 

16. WAP to display only those records whose percentage is greater that 60 and less that 80. Also count the total number of records. (name, class, marks in 3 subject)

 

OPEN "RESULT.DAT" FOR INPUT  AS #1

CLS

WHILE NOT EOF(1)

INPUT #1,N$,C,X,Y,Z

T= X+Y+Z

P= T/3

IF P>60 AND P<80 THEN PRINT N$,C,X,Y,Z

D=D+1

WEND

CLOSE #1

PRINT "Total number of records"; D

END

 

17. WAP to display only failed records assuming the pass marks for each subject is 40. (name, class, marks in 3 subject)

 

OPEN "RESULT.DAT" FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

INPUT #1,N$,C,X,Y,Z

IF X<40 AND Y<40 AND Z<40 THEN PRINT N$,C,X,Y,Z

WEND

CLOSE #1

END

 

18. WAP to create a sequential file "RESULT.DAT" and store name, class and marks in 3 subjects along with total and percentage.

 

OPEN "RESULT.DAT" FOR OUTPUT AS #1

DO

CLS

INPUT " Enter name"; N$

INPUT “Enter class”; C

INPUT " Enter marks in 3 subjects"; X,Y,Z

T= X+Y+Z

P=T/3

WRITE #1, N$,C,X,Y,Z,T,P

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

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

CLOSE #1

END

 

19. Wap to display name, class and marks in 3 subject from the data file “RESULT.DAT” along with total and percentage.

OPEN “RESULT.DAT” FROM INPUT AS #1

CLS

WHILE NOT EOF(1)

INPUT #1, N$, C, X, Y, Z

T= X+Y+Z

P= T/3

PRINT N$, C, T, P

WEND

CLOSE #1

END

 

20. Wap to display all records whose marks in computer is more than 80 from the data file “RESULT.DAT” (name, class, marks in english, nepali, computer).

 

OPEN “RESULT.DAT” FOR INPUT AS #1

CLS

WHILE NOT EOF(1)

INPUT #1, N$, C, X, Y, Z

IF Z= 80 THE PRINT N$, C, X, Y, Z

WEND

CLOSE #1

END