Question answer of the file handling in qbasic for SEE
Introduction:
QBasic is a popular programming language used by students and beginners to learn programming concepts. File handling is an essential aspect of programming that involves reading, writing, and manipulating data stored in files. Understanding file handling in QBasic is crucial for SEE and grade 10 students to excel in their exams. In this article, we will provide a comprehensive guide to file handling in QBasic for SEE and grade 10 students, along with frequently asked questions and answers to help them prepare for their exams.
1) What is File Handling in QBasic?
Ans: File handling refers to the process of reading, writing, and manipulating data stored in files. In QBasic, files can be stored on a computer's hard drive, floppy disk, or any other storage device.
2) How to Open and Close a File in QBasic?
3) How to Read Data from a File in QBasic?
4) How to Write Data to a File in QBasic?
5) How to Append Data to a File in QBasic?
6) Write the difference between program file and data file.
Ans: Following
are the different between program file and data file.
Program
file |
Data file |
Programs
files are associated with providing access and execution of an actual program
that is stored and installed in the computer system. |
Data
file contains data and information needed for program to perform execution
successfully. Data files are linked with a program file during run time. |
7) How to Delete a File in QBasic?
To delete a file in QBasic, you need to use the KILL statement, followed by the file name. For example: KILL "file.txt" This statement deletes the file "file.txt" from the computer's storage device.8)Write the structure of file organization.
Ans: File
organization is a manner in which data are stored, organized and returned.
There are two files organization provided by q-basic.
a) Sequential
file organization:
It
is a file that should be accessed in a sequential manner starting at the
beginning of the data block and processing in order until an end-of-data marker
is met of the desired number of items has been read.
b) Random
file:
It
is a file which a key is used a pointer to its appropriate record stored on a
disk.
9) How many types of file modes are available in file handling?
Ans: File modes available in file
handling are as follows:
i) Input (I) ii)
Output (O) iii) Append (A) iv) Binary (B) v) Random (R)
10) Write the operations of different modes of sequential file
handling.
Output
Mode:
It
is used to create a new data file and write data in it. If the file already
exists its current contents will be destroyed.
Input
Mode:
It
is used to retrieve records or contents of existing data file.
Append
Mode:
It
is used to add more records in existing file. If the specified file does not exist
APPEND mode creates it.
11) Write the function of the following with syntax.
a) Opening
file (create a file): (OUTPUT):
To
open a file first creates a file using OPEN statement.
Syntax:
OPEN "File name"
for MODE as # [Channel no]
Example:
OPEN "avn.dat" for OUTPUT as # 2
b) Writing
a file (WRITE):
It
writes data to the sequential file. It stores the value to a specific file which is enter from INPUT statement.
Syntax:
WRITE #[Channel no],
[expression list]
Example:
WRITE #2, n$,a,b$
c) Reading from a file(INPUT):
Reading
data from a file that has been previously opened as INPUT is
accomplished using the input statement.
Syntax:
INPUT #<Channle no>,
[expression list]
Example:
INPUT #2, a$,a,c
d) Appending a file: (APPEND):
It is
the process of adding records to the end of a file that previously exists on in your disk (C: D: or E:)
Syntax:
OPEN "file name"
for MODE as # <channel no>
Example:
OPEN "avn.dat" for APPEND as #2
e) Closing a file (CLOSE) (SEE
2073)
Close
statement is responsible for Transferring the data currently in primary memory
to secondary memory.
Syntax:
Close #<channel no>
Example:
CLOSE #2
12) Write the function and syntax of file system commands.
(Immediate mode commands)
a) CHDIR:
Function:
This command is used to change the current directory
Syntax:
CHDIR <path>
Example:
CHDIR "C:\program\qbasic"
b) MKDIR:
Function:
This command creates a specified sub-directory inside the current directory.
Syntax:
MKDIR <directory name>
Example:
MKDIR "A:\qbasic"
c) RMDIR:
Function:
This command is used to remove or delete only sub-directory from a disk.
It can remove only empty sub-directory.
Syntax:
RMDIR <path>
Example:
RMDIR "C"\program\qb"
d)
FILES:
Function:
This command display the files on the disk. The directory and
sub-directory also displayed on the screen.
Syntax:
FILES <file specification>
Example:
FILES "C:\qbasic\*.dat"
e) NAME: (SEE 2073)
Function:
This command is used to change the name of a disk file or directory.
Syntax:
NAME <old file name> as <new file name>
Example:
NAME "avn.bas" as "aishwarya.bas"
f) SHELL:
Function:
This command is used to enter the DOS prompt temporarily.
Syntax:
SHELL <command string>
Example: SHELL
Note: To
return back in q-basic screen, type EXIT and
press enter key.
13) Write the function of the
following:
Line
Input:
It
is used to read an entire line of input from the keyboard and store in one
string variable.
INPUT
#:
This
statement is used to retrieve data items or fields from a sequential file
record and store them into a list of variable.
Line
Input #:
This
statement is used to retrieve an entire record from a sequential file and store
it into one string variable.
LOC:
It
returns the current position within a file.
Syntax: LOC (file number)
LOF:
It
returns the length of a file in bytes.
Syntax: LOF
(file number)
Print
# and Print # using:
Print# writes
data to the file and Print# using writes formatted to the file.
Function
and use of QBASIC statements (Modular programming and File Handling).
1.
Write down the function of the following statement.
(Specification Grid 2065)
KILL :
It deletes the file or files from specified drive. (Supp.
2070, SEE 2073 Supp, SEE 2074)
MKDIR: It
creates a directory or sub-directory in specified drive. (SLC
2065)
NAME: It
renames the file. (SLC 2069, 2070, SEE 2073)
CLOSE: It
close the statements of dat file. (SLC 2070, supp
2070, SEE 2073, 2073 supp, SEE 2074)
RMDIR: It
removes the directory or sub directory from specified drive.
NAME: It
renames the files. (SLC 2066, SLC supplementary 2066)
FILES:
List files and directories from specified location. (SEE
2075)
KILL:
Deletes files from a specified location. (SLC
2067, 2069)
INPUT: It
is used to open an existing file and read the records of file.
MKDIR: It
creates a directory or subdirectory in specified drive. (SLC
2068)
CHDIR: It
is used to change the current directory.
SHELL: It
is used to enter the DOS prompt temporarily.
LINE
INPUT#: It is used to read and entire line without delimiters from a
sequential file into a string variable.
INPUT#: It
is used to read data items from a sequential file and assign them to program
variable.
WRITE
#: It is used to send one or more data items to the
specified sequential data file. (SEE
2075)
INPUT$: It
is used to reads the specified number of characters from the data files.
OPEN: It
is used to open a sequential file.
OUTPUT: It
is used to open a file first creates a file using OPEN statement.
APPEND: It
is used to adding records to the end of file that previously exists on disk.
CLOSE: It
is used to Transferring the data currently in primary to secondary memory.
EOF: It
is usedto indicate the end of a sequential file. (SLC 2068)
CALL: It
is used to Transfer control to another procedure. (SLC
2071)
PRINT
#: It is used to send a values to a data file.
SYSTEM: It
is used to close the QBASIC program.
SHARED: This
statement is used to make the variable global between main module and
sub module.(SLC
2071)
COMMON
SHARED: It defines global variable that can be shared throughout a
program or between chained programs.
FAQs:
Conclusion:
File handling is an essential aspect of programming that involves reading, writing, and manipulating data stored in files. Understanding file handling in QBasic is crucial for SEE and grade 10 students to excel in their exams. In this article, we provided a comprehensive guide to file handling in QBasic for SEE, along with frequently asked questions and answers to help you prepare for your exams. By following the guidelines outlined in this article, you should be able to master file handling in QBasic and succeed in your programming endeavors.
No comments:
Post a Comment