21. Which function is used to set the file position in C++ file handling? A. file.seek() B. seekg() C. file.position() D. setPosition() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
22. What is the purpose of the ios::ate flag in C++ file handling? A. Sets the get position pointer at the beginning of the file B. Sets the get position pointer at the end of the file C. Sets the get position pointer at the current position in the file D. Sets the get position pointer to the specified position in the file Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
23. In C++, how do you check if a file has reached the end while reading? A. file.eof() B. eof(file) C. file.end_of_file() D. endOfFile(file) Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
24. Which function is used to rewind the file pointer to the beginning of the file in C++? A. rewind() B. reset() C. file.rewind() D. file.seekg(0) Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
25. What is the function used to read a single character from a file in C++? A. file.getch() B. readChar() C. file.readChar() D. get() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
26. Which of the following is not a valid file mode in C++? A. w B. a C. r D. x Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
27. How do you delete a file in C++? A. file.delete() B. deleteFile() C. removeFile() D. remove() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
28. Which function is used to return the current file pointer position in C++? A. currentPos() B. tellg() C. position() D. getFilePos() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
29. Which function is used to check if a file is open or not in C++? A. isOpen() B. isFileOpen() C. file.is_open() D. fileOpened() Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
30. What happens if you try to open a file that does not exist in C++ without specifying any flags? A. The file will be created B. An error will occur C. The program will wait indefinitely D. The file will be opened in read mode Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board