Solution of File's Question2 of QBASIC
1. Write a program 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
CLS
INPUT "Enter name";N$
INPUT "Enter Address";A$
INPUT "Enter Age";Age
INPUT "Enter Gender";G$
INPUT "Enter Salary";S
WRITE #1, N$,A$,Age,G$,S
CLOSE #1
END
2. A data file "LIB.TXT" consists of Book's name, Author 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,BN$,AN$,P
PRINT BN$,AN$,P
c=c+1
WEND
CLOSE #1
PRINT "Total number of records is ";c
END
3. A sequential data file "EMP.DAT" contains name, post and salary 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=S*15/100
PRINT N$,P$,S,T
WEND
CLOSE #1
END
OPEN "Employee.dat" FOR OUTPUT AS #1
CLS
INPUT "Enter name";N$
INPUT "Enter Address";A$
INPUT "Enter Age";Age
INPUT "Enter Gender";G$
INPUT "Enter Salary";S
WRITE #1, N$,A$,Age,G$,S
CLOSE #1
END
2. A data file "LIB.TXT" consists of Book's name, Author 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,BN$,AN$,P
PRINT BN$,AN$,P
c=c+1
WEND
CLOSE #1
PRINT "Total number of records is ";c
END
3. A sequential data file "EMP.DAT" contains name, post and salary 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=S*15/100
PRINT N$,P$,S,T
WEND
CLOSE #1
END
Comments