Create a sequential data file staff.inf to store name, address, post and salary for a few employees. Program should allow the user to enter the records as many as they want.
Answers
Answer:
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