Introduction to Programming MCQs with Answers
Practice important Introduction to Programming MCQs with answers and explanations.
Multiple Choice Questions
Q291: What is the function of tellg() in relation to file length?
- A: Determines the file's total size
- B: Determines the position of the next character to be read
- C: Determines the size of the string inside the file
- D: Determines the position of the last character in the file
View Answer
B
Q292: Which functions are used to determine the current position of the file pointer?
- A: strlen() and seekg()
- B: strlen() and seekp()
- C: tellg() and tellp()
- D: tellg() and seekg()
View Answer
C
Q293: What is the purpose of seekp() in file handling?
- A: Move the file pointer forward by one byte
- B: Move the file pointer to a specific position for writing
- C: Move the file pointer to the end of the file
- D: Move the file pointer to the beginning of the file
View Answer
B
Q294: What does ios::end indicate when used in file handling?
- A: Beginning of the file
- B: Current position in the file
- C: End of the file
- D: Middle of the file
View Answer
C
Q295: How can you determine the length of a file using tellg() and seekg()?
- A: Move to the end of the file with seekg() and use tellg
- B: Count the characters one by one using tellg()
- C: Use tellp() to calculate the length
- D: Move to the start of the file with seekg() and use tellg
View Answer
A
Q296: What is the minimum size of data that can be read from or written to a disk?
- A: 1 byte
- B: 53 bytes
- C: 1 block
- D: 1024 bytes
View Answer
C
Q297: What function is used to determine the actual length of data in a file?
- A: seekp()
- B: tellp()
- C: seekg()
- D: tellg()
View Answer
D
Q298: Which function is used to move the file pointer to the end of the file?
- A: seekg(0, ios::beg)
- B: seekg(0, ios::end)
- C: tellg()
- D: seekp(0, ios::end)
View Answer
B
Q299: Why is seekg() used before performing operations on a file?
- A: To find the start of the file
- B: To find the end of the file
- C: To find a specific location in the file
- D: To calculate the file size
View Answer
C
Q300: What is a potential issue when updating data in the middle of a file?
- A: The file structure may get corrupted
- B: Data may be lost
- C: The disk may get damaged
- D: The file will get locked
View Answer
A