नेपालको नक्सा:
SchoolNotes
This blog is designed to assist school-level students.
Thursday, June 26, 2025
Wednesday, March 26, 2025
Sunday, March 23, 2025
FILE HANDLING (SOLVED)
FILE HANDLING (SOLVED)
1. Write a QBASIC program to create a file named including the name, class, and roll number of a student.
OPEN "std.dat" FOR OUTPUT AS #1
CLS
INPUT "Enter student name: ", name$
INPUT "Enter student class: ", class$
INPUT "Enter roll number: ", roll$
WRITE #1, name$, class$, roll$
CLOSE #1
PRINT "Student data saved successfully in std.dat!"
END
2. Write program to read and display the name, class and roll number of students.
CLS
OPEN "std.dat" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, name$, class$, roll$
PRINT "Name: "; name$; ", Class: "; class$; ", Roll No.: "; roll$
LOOP
CLOSE #1
END
3. Read data from a file and calculate total marks:
CLS
OPEN "marks.dat" FOR INPUT AS #1
total = 0
DO WHILE NOT EOF(1)
INPUT #1, marks
total = total + marks
LOOP
PRINT "Total Marks: "; total
CLOSE #1
END
4. Search for a specific student's data in:
CLS
OPEN "records.dat" FOR INPUT AS #1
INPUT "Enter name to search: ", searchName$
found = 0
DO WHILE NOT EOF(1)
INPUT #1, name$, details$
IF name$ = searchName$ THEN
PRINT "Details: "; details$
found = 1
END IF
LOOP
IF found = 0 THEN PRINT "Student not found!"
CLOSE #1
END
5. Count and display the number of records in a file:
CLS
OPEN "students.dat" FOR INPUT AS #1
count = 0
DO WHILE NOT EOF(1)
LINE INPUT #1, data$
count = count + 1
LOOP
PRINT "Total Records: "; count
CLOSE #1
END
6. Display specific fields from (e.g., names only):
CLS
OPEN "data.dat" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, name$, info$
PRINT "Name: "; name$
LOOP
CLOSE #1
END
7. Write a QBASIC program to create a file named including the name, class, and roll number of a student.
CLS
OPEN "std.dat" FOR OUTPUT AS #1
INPUT "Enter student name: ", name$
INPUT "Enter student class: ", class$
INPUT "Enter roll number: ", roll$
WRITE #1, name$, class$, roll$
CLOSE #1
PRINT "Student data saved successfully in std.dat!"
END
8. Write a QBASIC program to create a text file named . The file should store the names and marks of five students entered by the user.
OPEN "StudentInfo.txt" FOR OUTPUT AS #1
CLS
FOR i = 1 TO 5
INPUT "Enter student name: ", name$
INPUT "Enter student marks: ", marks
WRITE #1, name$, marks
NEXT i
CLOSE #1
PRINT "Data written to StudentInfo.txt successfully!"
END
9. Write a QBASIC program to read and display the contents of a text file named . Assume the file contains student names and grades.
CLS
OPEN "Grades.txt" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, name$, grade$
PRINT "Name: "; name$; ", Grade: "; grade$
LOOP
CLOSE #1
END
10. Write a QBASIC program that appends new records (names and scores) to an existing file called without overwriting its current contents.
CLS
OPEN "Results.txt" FOR APPEND AS #1
INPUT "Enter name: ", name$
INPUT "Enter score: ", score
WRITE #1, name$, score
CLOSE #1
PRINT "Record added to Results.txt successfully!"
END
11. Write a QBASIC program to count and display the total number of lines present in a text file named.
CLS
OPEN "Data.txt" FOR INPUT AS #1
lineCount = 0
DO WHILE NOT EOF(1)
LINE INPUT #1, text$
lineCount = lineCount + 1
LOOP
PRINT "Total number of lines: "; lineCount
CLOSE #1
END
12. A sequential data file called "STUDENT.DAT" has stored data under the field heading Registration No., Class, Section, Name, Date of Birth and Gender. Write a program to display all the information of class NINE students whose gender is 'FEMALE'.
OPEN “STUDENT.DAT” FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
INPUT #1, R, CL, SE$, N$, D$, G$
IF UCASE$(G$)=”FEMALE” AND CL=9 THEN
PRINT R, CL, SE$, N$, D$, G$
END IF
WEND
CLOSE #1
END
Friday, March 21, 2025
Important Points: Computer Programming
Computer Programming/Modular Programming/File Handling
- Modular Programming: Process of writing program in multiple modules
- Main Module: The main part of the program inside which several sub modules are created
- Sub program: A group of statements written in a separate module to perform one or more tasks
- Formal Parameter: Parameter used while declaring and defining sub-program or user-defined functions
- Actual Parameter: Parameter used while calling sub-procedure or user defined function
- Local Variable: The variable which is recognized only inside the module where it is declared
- Global Variable: The variable which can be accessed from all the modules.
- File Handling: File handling is a mechanism to work with file so that we can read and write data from and into a disk file through QBASIC program.
- Output Mode: Output mode creates a new file and opens it to store data.
- Append Mode: Append mode opens an existing file to add records.
- Input Mode: Input mode opens and existing file to read records.
- File management command: File management command operates various task in a program. (Ex. FILES, MKDIR, CHDIR, RMDIR, NAME...AS, KILL and SYSTEM)
Full Forms: DBMS
DBMS
DBMS: Database Management System
RDBMS: Relational Database Management System
SQL: Structured Query Language
DDL: Data Definition Language
DML: Data Manipulation Language
ACID: Atomicity, Consistency, Isolation, Durability
ODBC: Open Database Connectivity
DAO: Data Access Objects
VBA: Visual Basic for Applications
OLE: Object Linking and Embedding
Full Forms: Contemporary Technology
Contemporary Technology
e-Commerce: Electronic Commerce
IaaS: Infrastructure as a Service
SaaS: Software as a Service
PaaS: Platform as a Service
AI: Artificial Intelligence
VR: Virtual Reality
ICT: Information and Communication Technology
E-Gov: Electronic Government
WiFi: Wireless Fidelity
GPS: Global Positioning System
W-LAN: Wireless Local Area Network
QoS: Quality of Service
IoT: Internet of Things
Full Forms: E-Commerce
E-Commerce
EDI: Electronic Data Interchange
B2C: Business to Consumer
B2B: Business to Business
C2C: Consumer to Consumer
M-Commerce: Mobile Commerce
PDA: Personal Digital Assistant
EFT: Electronic Funds Transfer
CoD: Cash on Delivery
EFTPOS: Electronic Funds Transfer at Point of Sale
Map of Nepal
नेपालको नक्सा: नेपालको नक्सा: नेपालको नक्सा: नेपालको नक्सा: नेपालको नक्सा: नेपालको नक्सा: नेपालको नक्सा:

Most viewed!
-
Modular programming solutions 1. Program to calculate perimeter and area of a rectangle. Use sub procedure to calculate perimeter and funct...
-
PRACTICE QUESTIONS: 'DEBUG' Re-write the following programs after correcting the bugs: Question no. 1 CLS OPEN "Marks.dat...
-
VERY SHORT ANSWER (KEYWORDS ONLY): Programming: QBASIC, Modular programming, File Handling, C programming 1. What is QBASIC? Begi...
-
Computer Programming/Modular Programming/File Handling Modular Programming: Process of writing program in multiple modules Main Module: The...
-
VERY SHORT ANSWER: Chapter Networking and Telecommunication 1. What is a computer network? Interconnected computers 2. What is LA...