Search Tutorials


C File Handling MCQ Questions and Answers | JavaInUse

C File Handling MCQ Questions and Answers

Q. What is a file in C?

A. A named collection of data stored permanently on a storage device
B. A temporary storage area in RAM
C. A data structure used for organizing data in memory
D. A method of transmitting data over a network

Q. Which function in C is used to open a file?

A. fopen()
B. freopen()
C. open()
D. create()

Q. What is the purpose of the "r" mode when opening a file in C?

A. To read data from the file
B. To write data to the file
C. To append data to the end of the file
D. To create a new file

Q. What is the purpose of the "w" mode when opening a file in C?

A. To read data from the file
B. To write data to the file, overwriting existing content
C. To append data to the end of the file
D. To create a new file

Q. What is the purpose of the "a" mode when opening a file in C?

A. To read data from the file
B. To write data to the beginning of the file
C. To append data to the end of the file
D. To create a new file

Q. Which function is used to close a file in C?

A. close()
B. fclose()
C. closefile()
D. endfile()

Q. What is the purpose of the fseek() function in C?

A. To read data from a file
B. To write data to a file
C. To change the file position indicator
D. To create a new file

Q. Which function is used to read a string from a file in C?

A. fgets()
B. fread()
C. fscanf()
D. fgetc()

Q. Which function is used to write a string to a file in C?

A. fputs()
B. fwrite()
C. fprintf()
D. fputc()

Q. What is the purpose of the ftell() function in C?

A. To read data from a file
B. To write data to a file
C. To get the current file position indicator
D. To create a new file





Q. What is the purpose of the rewind() function in C?

A. To read data from a file
B. To write data to a file
C. To reset the file position indicator to the beginning of the file
D. To create a new file

Q. What is the purpose of the feof() function in C?

A. To check if the end of the file has been reached
B. To check if the file is open
C. To check the size of the file
D. To check if the file exists

Q. What is a file in C?

A. A named collection of data stored permanently on a storage device
B. A temporary storage area in RAM
C. A data structure used to organize data in memory
D. None of the above

Q. Which function in C is used to open a file?

A. fopen()
B. freopen()
C. open()
D. None of the above

Q. What is the return value of the fopen() function if the file opening is successful?

A. 0
B. 1
C. A FILE pointer
D. NULL

Q. What is the purpose of the "r" mode when opening a file in C?

A. To open a file for reading
B. To open a file for writing
C. To append data to a file
D. To create a new file

Q. What is the purpose of the "w" mode when opening a file in C?

A. To open a file for reading
B. To open a file for writing
C. To append data to a file
D. To create a new file

Q. What is the purpose of the "a" mode when opening a file in C?

A. To open a file for reading
B. To open a file for writing
C. To append data to a file
D. To create a new file

Q. Which function is used to read data from a file in C?

A. fread()
B. fwrite()
C. fgetc()
D. fgets()

Q. Which function is used to write data to a file in C?

A. fread()
B. fwrite()
C. fputc()
D. fprintf()

Q. What is the purpose of the fclose() function in C?

A. To close a file and release associated resources
B. To flush the output buffer to the file
C. To reposition the file pointer to the beginning of the file
D. To change the file mode

Q. What is the purpose of the feof() function in C?

A. To check if the end of the file has been reached
B. To flush the output buffer to the file
C. To reposition the file pointer to the beginning of the file
D. To get the current position of the file pointer

Q. What is the purpose of the fseek() function in C?

A. To set the file pointer to a specified position
B. To flush the output buffer to the file
C. To check if the end of the file has been reached
D. To get the current position of the file pointer

Q. What is the purpose of the rewind() function in C?

A. To set the file pointer to the beginning of the file
B. To flush the output buffer to the file
C. To check if the end of the file has been reached
D. To get the current position of the file pointer

Q. What is the purpose of the ftell() function in C?

A. To set the file pointer to a specified position
B. To get the current position of the file pointer
C. To flush the output buffer to the file
D. To check if the end of the file has been reached

Q. What is the purpose of the fflush() function in C?

A. To flush the output buffer to the file
B. To set the file pointer to the beginning of the file
C. To get the current position of the file pointer
D. To check if the end of the file has been reached