PRACTICE • LEARN • GROW
Module 11: File I/O - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 11: File I/O - Final Quiz Progress
0 of 8 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What is the key difference between file opening modes
"w" and "a" in C?
A.
"w" is for write-only; "a" is for read-only
B.
"w" truncates/wipes existing file contents to 0 bytes; "a" preserves existing data and appends new content to the end
C.
"w" creates a file; "a" fails if the file does not exist
D.
"w" opens in binary; "a" opens in text
Explanation & Key
Correct Answer:
2
What does
fopen() return if the file cannot be opened (e.g. file not found or permission denied)?
A.
-1
B.
NULL
C.
EOF
D.
0
Explanation & Key
Correct Answer:
3
What is the purpose of appending
"b" to file modes (such as "rb" or "wb")?
A.
Enables buffer compression
B.
Instructs the runtime to treat the file as binary, disabling newline translation (CRLF ↔ LF) on Windows platforms
C.
Bypasses file permission checks
D.
Encrypts the file
Explanation & Key
Correct Answer:
4
Why is the loop
while (!feof(fp)) considered a classic anti-pattern in C file reading?
A.
It causes a syntax error
B.
feof() only returns true AFTER a read operation attempts to read past the end of the file, resulting in the final character or record being processed twice
C.
It exhausts file descriptors
D.
feof cannot be used with text files
Explanation & Key
Correct Answer:
5
Which standard functions are designed for reading and writing raw binary data blocks directly between memory and disk?
A.
fprintf() and fscanf()
B.
fputs() and fgets()
C.
fread() and fwrite()
D.
fputc() and fgetc()
Explanation & Key
Correct Answer:
6
What does
fclose(fp) return upon successfully flushing and closing a file stream?
A.
0
B.
1
C.
EOF
D.
NULL
Explanation & Key
Correct Answer:
7
How do you determine the total size of a file in bytes using
fseek() and ftell()?
A.
fseek(fp, 0, SEEK_SET); long size = ftell(fp);
B.
fseek(fp, 0, SEEK_END); long size = ftell(fp);
C.
long size = sizeof(fp);
D.
fseek(fp, 0, SEEK_CUR); long size = feof(fp);
Explanation & Key
Correct Answer:
8
What is the role of
fflush(fp) when writing to a buffered file stream?
A.
It clears the file from disk
B.
It forces any unwritten data remaining in the stream's user-space buffer to be written immediately to the physical disk
C.
It closes the file stream
D.
It rewinds the file indicator to byte 0
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong