Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Thursday, February 17, 2022

OUTPUT mode of File Handling

 Solved Examples of 

OUTPUT mode in File Handling


1. Create a sequential data file "STD.DAT" to store student name and marks obtained in three subjects English, Math and Science for some students.  (Specification Grid 2065)

OPEN "STD.DAT" FOR OUTPUT AS #2

Top:

CLS

INPUT "Enter name=";n$

INPUT "Enter marks of English=";eng

INPUT "Enter marks of Maths=";math

INPUT "Enter marks of Science=";sci

WRITE #2, n$, eng,math,sci

INPUT "Do you need more records(Y/N)?";Ans$

IF Ans$="y" OR Ans$="Y" THEN GOTO top

CLOSE #2

END

 

2. Write a program to store books name, writers name and price of the book in a sequential data file “STORE.DAT”. The program should be continue according to the your choice . (SLC 2063)

OPEN “STORE.DAT” FOR OUTPUT AS #2

TOP:

INPUT “Enter book’s name=”;b$

INPUT “Enter Writer’s name=”;w$

INPUT “Enter price of book=”;p

WRITE #2, b$, w$, p

INPUT “Do you want to add more records (Y/N)”;ch$

IF ch$=”Y” or ch$=”y” THEN GOTO top

CLOSE #2

END

 

3. Write a program to store records regarding the information of book number, book's name writer's name in a sequential data file called "Library.dat". (SLC 2065)

OPEN "Library.dat" FOR OUTPUT AS #1

Avn:

INPUT "Enter book number=";n

INPUT "Enter books name=";b$

INPUT "Enter authors name=";a$

WRITE #1,n,b$,a$

INPUT "Store more records?";Ans$

IF Ans$="Y" OR Ans$="y" THEN goto avn

CLOSE #1

END

 

4. WAP to create a data file “employee.dat” to store name, address, age, gender and salary of employees.

OPEN “employee.dat” FOR OUTPUT AS # 1

DO

INPUT “Enter name”;name$

INPUT “Enter address=”;add$

INPUT “Enter age=”;age

INPUT “Enter gender=”;g$

INPUT “Enter salary=”;sal

WRITE #!, name$, add$, age, g$, sal

INPUT “Do you want to continue..?”;Ans$

LOOP WHILE UCASE$(Ans$) =”y”

CLOSE #!

END

 

5. WAP to create a data file "result.dat" and store name, class, roll no and any 4 subjects marks of ten  students.

CLS

OPEN "result.dat" FOR OUTPUT AS #2

FOR x= 1 to 10

INPUT "Enter name=";n$

INPUT "Enter Roll no.=";r

INPUT "Enter Class=";c$

INPUT "Enter Marks of English=";eng

INPUT "Enter Marks of Maths=";math

INPUT "Enter Marks of Computer=";co

INPUT "Enter marks of Science";sc

WRITE #2, n$,r,c$,eng,math,co,sc

NEXT x

CLOSE #2

END

 

 

6. Create a sequential data file “HOTEL.DAT” to store  name, address, and contact number. Program should terminate according with user’s choice.

OPEN “HOTEL.DAT” FOR OUTPUT AS #1

DO

CLS

INPUT “Enter customers name”; CN$

INPUT “Enter add”; A$

INPUT “Enter contact number”; P#

WRITE #1, CN$, A$, P#

INPUT “Do you need more records(Y/N)”; CH$

LOOP WHILE LCASE$(CH$) = “y”

CLOSE #1

END

 

7. WAP to create a sequential data file ‘teldir.dat’ to store Name, Address and Telephone number of employee according to the need of the user. (SLC 2069)

OPEN “teldir.dat” FOR OUTPUT AS #1

DO

INPUT “Enter Name:”n$

INPUT “Enter address:”;a$

INPUT “Enter Contact number:”;t$

WRITE #1, n$,a$,t$

INPUT “Do you want to add more records (Y/N)?”;ch$

LOOP WHILE UCASE$(ch$)= “Y”

CLOSE #1

END

 

8. Create a data file to store the records of few employees having Name, Address, Post, Gender and Salary fields.  (SEE 2073)

OPEN “std.rec” FOR OUTPUT AS #1

top:

CLS

INPUT “Enter Name of employee”; N$

INPUT “Enter Address”; A$

INPUT “Enter Post of employee”; P$

INPUT “Enter gender of employee”; G$

INPUT “Enter Salary of employee”; S

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

INPUT “Do you want to continue”; CH$

IF (UCSAE$(ch$)="Y" THEN GOTO top

CLOSE #1

END

 

 9. Write a program to store Roll no., Name, Class and Address of any twenty students. (SEE 2074)

OPEN "Student.dat" FOR OUTPUT AS #1
 FOR I = 1 TO 20
INPUT "Enter Roll Number", rn
INPUT "Enter Name", name$
INPUT "Enter Class", cl
INPUT "Enter Address", ad$
WRITE #1, rn, name$, cl, ad$
NEXT I
CLOSE #1
 END

 

10. Write a program to create a sequential data file “salary.data” to store Name, salary and post of the programmer according to the need of the user. (SEE 2075 state 2)

OPEN “SALARY.dat” FOR OUTPUT AS #1

DO

CLS

INPUT “Enter Name”; Name$

INPUT “Enter salary”; Sal

INPUT “Enter Post”; Po$

WRITE #1, Name$, Sal, Po$

INPUT “Do you want to continue(Y/N)”; CH$

LOOP WHILE LCASE$(CH$)=”y”

CLOSE #1

END

 

11. WAP to create a sequential file "store.dat" and store code, name, rate of the item. The program should prompt the user to enter more data.

OPEN "store.dat" FOR OUTPUT AS #4

DO

INPUT "Enter item code=";c

INPUT "Enter Item name=";n$

INPUT "enter rate=";r

WRITE #4, c, n$,r

INPUT "Do you want to conti……(y/n)";Ans$

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

CLOSE #4

END

 

12. WAP to create a sequential data file “Price.txt” and store name, quantity and price of the item. Program should terminate according to the user’s choice.

OPEN “price.txt” FOR OUTPUT AS #1

DO

CLS

INPUT “Enter item name”; N$

INPUT “Enter quantity”; Qt

INPUT “Enter rate”; Ra

WRITE #1, N$, Qt, Ra

INPUT “Do you want to continue(Y/N)”;CH$

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

CLOSE #1

END

 

13. WAP  to input students name and any three subjects marks.  In data file "result.dat" store only those records that are passed in all the subjects  The program should be terminating according to the users choice.  [Hints: : Pass marks is 35 in each subjects.]

OPEN"result.txt" FOR OUTPUT AS  #1

top:

INPUT "Enter name, marks in English, Maths and Computer ";n$,e,m,c

IF e>=35 AND  m>=35 AN  c>=35 THEN

WRITE #1,n$,e,m,c

 ENDIF

 INPUT "Want to add another records ";ch$

IF UCASE$(ch$)="Y" THEN GOTO top

CLOSE #1

 END

 

14. WAP to create a data file “person.dat” and store the name, post and salary of 15 employees.

OPEN “person.dat” FOR OUTPUT AS #1
FOR x= 1 TO 15

INPUT “ENTER THE NAME ” ;  Na$
INPUT “ENTER THE POST” ; Po$
INPUT “ENTER THE SALARY” ; Sal$
WRITE#1 , Na$,Po$,Sal$
NEXT

CLOSE#1
END


No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages