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 deviceB. 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 fileB. 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 fileB. 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 fileB. 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 fileB. 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 fileB. To write data to a file
C. To get the current file position indicator
D. To create a new file