Summary

This document contains CS201 final term quizzes. It includes questions about file operations in C++. This is a computer science past paper for an undergraduate course.

Full Transcript

CS201 Final Quizes ch # 19 to 42 Lecture # 19 1)What does tellg() return? a) Current write position in a file b) Current read position in a file c) Length of the file d) Error code for file operations 2)Which function is used to move the file pointer for writing operations? a)...

CS201 Final Quizes ch # 19 to 42 Lecture # 19 1)What does tellg() return? a) Current write position in a file b) Current read position in a file c) Length of the file d) Error code for file operations 2)Which function is used to move the file pointer for writing operations? a) seekg() b) seekp() c) tellg() 1 d) ios::write 3)What happens when you try to move the file pointer beyond the end of the file? a) File pointer wraps around to the beginning of the file b) File pointer stays at the end of the file c) File pointer moves backward by default d) File operations stop working completely 4)Which of the following statements moves the file pointer 10 bytes backward from the current position? a) seekp(10, ios::beg) b) seekg(-10, ios::cur) c) seekg(10, ios::end) 2 d) seekp(-10, ios::end) 5)What is the output of the following code snippet if the file contains 150 bytes? ifstream file("example.txt"); file.seekg(0, ios::end); cout

Use Quizgecko on...
Browser
Browser