Short Questions
Q.l. What is . a stream?
A logical interface to a file is known as stream. A stream is associated with a file using an
open operation. The stream is disassociated from a file using a close operation.
Q.2. What do you mean by text stream?
A text stream is a sequence of characters. A certain character translation may occur in a
text stream. For example, a new line may be converted to a carriage return /line feed pair. ,Q.3.
What is binary stream?
A binary stream is a sequence of bytes. The translation is not performed in binary stream . It
exists with a one-to-one correspo~dence to the external ,devices. It means that the number of
bytes written or read is the same as the number of bytes 'on the external device. Q.4. What is EOF
marker?
A text file a named collection of characters saved in secondary storage such as disk .
The text file has no fixed size. A special end-of~file character is used to indicate the end of a text
file. It is placed after the last character in the . file. It is denoted by EOF in C language.
Q.5. What is Newline marker? .
The ENTER ~ey is used , to move the cursor to the next line in a text editor such as
Notepad . A newline character is placed . at the end of each line when the user presses Enter
key. The newline is denoted . by \n in C . '
Q.6. Define a pointer. ,
A type of variable that is used to store the memory address of a memory cell is known as
pointer. It normally stores the memory address of a variable or object. The data tjpe of a pointer
must be the same as data type oithe variable whose memory address is stored in it . Q.7. What is
file pointer?
File pointer is a pointer that refers to a file on the secondary storage. It is a variable of type
FILE that is defined in stdio.h. It is used to access and manipulate a data file . The file pointer is
associated with a file after dec;laration.
, Q.8. What is string? .
A collection of characters written in double quotations is called string. Character variables
are used to store a string. The length of string is given in brackets in declaration
statement such as char book[20]; ,
Q.9. What is meant by "R+" and" A+" ,
These are two modes for ope ning files. R+ is used to open a file in read/write mode .
The data can be read and written to a file . The file must exist already. A+ is used to open a file in
append mode. The new data is written at the 'end of existing data. The existing data can also be
read.
Q.I0. Name different opening modes provided by C language.
Different"'opening modes provided by C language are read mode, write mode, append
mode, read/write mode and append mode. '
Q.ll. What is meant by fgets( ) function? .
Data can be read from text file one character at a time by usingfgetc function . Its
syntax is as follows: .
ch = fgetc(File: .-Pointer);
Q.12. Write the prototype of fopen function used for opening a file.
The function fopen is used to open a file. Its prototype is as follows:
File_Pointer = fopen(File_Name, Mode);
In the prototype, File_Pointer is the name of file pointer declared in the program.
File_Name is the name of data file to be opened . Mode indicates the mode . in which the file is
to be opened. . ,
Q.13. What is a text file?
,
A type of file that stores data as readable and printable characters is called text file .A
source program of C language is ,an example of text file. The user can easily view and read the contents
of a text file. It can also be printed to gel a hard copy.
Q.14. What functions are used to read and write characters to a file?
The fputc function is used to write one character in a file. The fgetc function is used to read one
a
character from file. The fputs function is used to write string of charaders in a file. The fgets function
is used to read string of characters from a file.
Multiple Choice
A file is stored in?
a. RAM . b. Hard disk c. ROM d. Cache
Which mode opens only an existing file for both reading and writing?
Which of the following functions is used to write a string to a file?
a. puts( ) .·b. putc( ) c.fputs( ) d. fgets( )
On successfully closing a file, the fclose( ) returns?
a. NULL b.O (Zer?) c. 1 (One)
An array script should b~:
a. int b. float c. dOl,lble d. an array
Which of the following character is used to mark the end of the string?
a. \0 b. /0 . c. \a d. \n
:"Vhich of the following function is used to copy a string to an array of characters/
a. strcpy b. strpcy c. strycp d. None
Whi,ch of the following are file handling functions?
a. fprintf( ) b. fscanf( ) C .both a and b
Which of the following functions is used to read character from a file?
a. getc( ) b. putc( ) c.fputs( ) d. fgets( )
Which of the following functions is used to write character to 'a file?
a. putc( ) b. putc( ) c.fputs( ) d. fgets( )
I
- I
a 6. a 5. b 4. c 3. b 2. b 1.
a 10 a 9. c ~. a .
. 7.