CBSE Class 12 Computer Science Question 52 of 136

Data File Handling — Question 17

Back to all questions
17
Question

Question 17

Which statement is used to change the file position to an offset value from the start?

  1. fp.seek(offset, 0)
  2. fp.seek(offset, 1)
  3. fp.seek(offset, 2)
  4. None of these
Answer

fp.seek(offset, 0)

Reason — The syntax for relative referencing is f.seek(offset, from_what). The statement f.seek(offset, 0) is used to change the file position to an offset value from the start, where 0 sets the reference point at the beginning of the file.