computer MCQs
12th • Chapter 14
46 Questions TextBook
1
What is a stream in C?
C
A logical interface to a file 2
Which function is used to open a file in C?
3
What does the mode "w" signify when opening a file?
4
If a file opened in "w" mode already exists, what happens to its contents?
C
Its contents are overwritten 5
What does EOF stand for?
6
Which header file contains the declarations for standard file handling functions?
7
What is a file pointer?
A
A memory address of the fileB
A variable of type FILEC
An integer representing the file sizeD
A character in the file 8
Which symbol is used to declare a pointer variable in C?
9
The function to close a file is:
10
Which function is used to read a single character from a file?
11
Which function is used to write a single character to a file?
12
In C, a string is implemented as an:
B
Linked list of characters 13
What character terminates every valid string in C?
14
Which function is used to copy a string to a string variable?
15
Which header file is required for using the strcpy() function?
16
The function fputs() writes a string to a file. What does it NOT write?
17
The function fgets() reads a string from a file until a newline, EOF, or what other condition is met?
B
num-1 characters have been readC
A tab character is readD
The string becomes too long 18
Which of the following modes opens a text file for both reading and writing, assuming the file must already exist?
19
What is a binary stream?
A
A sequence of characters with translationsB
A sequence of text linesC
A sequence of bytes with one-to-one correspondence to the external deviceD
A stream for images only 20
What is a text stream?
A
A sequence of bytes without translationB
A sequence of characters where translations like newline to CR/LF can occurC
A stream that can only contain lettersD
A stream that is always human-readable 21
How do you represent a pointer to an integer?
22
The 'a' mode for opening a file is used for what purpose?
A
Appending data to the end of a fileB
Reading a file from the beginningC
Overwriting an existing fileD
Creating a new file only 23
If a file does not exist and is opened in 'a' mode, what happens?
D
A NULL pointer is returned 24
What is the purpose of the second argument in the fopen() function?
A
To specify the file pointerB
To specify the file nameC
To specify the file opening modeD
To specify the buffer size 25
A pointer is a memory cell whose content is the ________ of another memory cell.
26
The contents of the memory location pointed to by a pointer 'var' are referred to as:
27
What does the function gets() do?
A
Reads a string from a fileB
Reads a character from the keyboardC
Reads a string from the keyboardD
Reads an integer from the keyboard 28
What symbol is used as a separator in the contacts.txt example file?
29
In the gotoxy(col, row) function, what does 'col' represent?
30
The functions fprintf() and fscanf() are similar to printf() and scanf() but they work with:
31
If a file is not in the current directory, what must be provided in its name to fopen()?
32
When providing an absolute path in a string in C, what must be done with backslashes?
A
They must be replaced with forward slashesB
They must be doubled (e.g., \\\\)D
They must be enclosed in quotes 33
What is returned by fgets() if an error occurs?
34
How can you declare a string variable named 'city' that can hold up to 20 characters?
35
The statement `name = "John";` for a string variable 'name' will cause:
36
What is the subscript of the first element in a C array?
D
Depends on the declaration 37
The `putc()` function takes a character and what other argument?
C
The file pointer (FILE *fp)D
The character's position 38
In a text file, what is placed at the end of each line when the ENTER key is pressed?
39
Which mode opens a text file for both reading and appending?
40
What does the `strlen()` function (used in the examples) do?
C
Concatenates two stringsD
Returns the length of a string 41
A file is defined as a set of related:
42
The `fscanf()` function is used for what purpose?
A
Formatted output to a fileB
Formatted input from a fileC
Unformatted input from a fileD
Opening a file in scan mode 43
The `fprintf()` function is used for what purpose?
A
Formatted input from a fileB
Unformatted output to a fileC
Formatted output to a fileD
Printing file properties 44
In C, a file can refer to:
B
The screen and keyboard onlyC
A disk file, the screen, the keyboard, a port, etc.D
A variable in memory only 45
Which function is used to move the cursor to a specific location on the screen in the examples?
46
What is the main advantage of `fprintf()` and `fscanf()`?
A
They are faster than other functionsB
They work with binary dataC
They make it easy to write a wide variety of data to a file using a text formatD
They automatically close the file