Thursday, February 23, 2023

File Management MCQs with Answers

C Programming File Management Important MCQs with Answers

1. Which function is used to open a file in C programming language?

(a) fopen()

(b) open()

(c) read()

(d) close()

Answer: (a) fopen()


2. What is the correct syntax of the fopen() function?

(a) fopen("filename", "mode");

(b) fopen("mode", "filename");

(c) fopen("filename", "access");

(d) fopen("access", "filename");

Answer: (a) fopen("filename", "mode");


3. Which mode is used to open a file for reading in C programming language?

(a) r

(b) w

(c) a

(d) x

Answer: (a) r


4. Which mode is used to open a file for writing in C programming language?

(a) r

(b) w

(c) a

(d) x

Answer: (b) w


5. What is the syntax of the fclose() function?

(a) fclose();

(b) fclose(file);

(c) fclose("filename");

(d) fclose(filename);

Answer: (b) fclose(file);


6. Find the purpose of the fseek() function in C File Management.

(a) To move the file pointer to a specific position in the file

(b) To close a file

(c) To read a file

(d) To write to a file

Answer: (a) To move the file pointer to a specific position in the file


7. What is the purpose of the remove() function in C File Management?

(a) To rename a file

(b) To delete a file

(c) To create a new file

(d) To close a file

Answer: (b) To delete a file


8. What is the syntax for opening a file in C programming?

(a) FILE *fp = fopen("filename", "mode");

(b) file fp = fopen("filename", "mode");

(c) FILE *fp = fopen("mode", "filename");

(d) none of these

Answer: (a) FILE *fp = fopen("filename", "mode");



No comments:

Post a Comment