Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.7k views
in Computer by (69.4k points)

Observe the program segment given below carefully, and answer the question that follows: class Book

{

int Book_no; char Book_name[20];

public:

//function to enter Book details

void enterdetails();

//function to display Book details

void showdetails();

//function to return Book_no

it Rbook_no()

{ return book_no; }

};

void Modify(Book NEW)

{ fstream File; File.open("BOOK.DAT",ios::binary|ios::in|ios::out);

Book OB;

int Recordsread=0,Found=0; while(!Found&&File.read((char*)&OB,sizeof(OB))) { 

Recordsread++;

if(NEW.RBook_no()==OB.RBook_OB())

{ _______________ //Missing Statement 

File.write((char*)&NEW,sizeof(NEW));

Found=1;

}

else

File.write((char*)&OB,sizeof(OB));

}

if(!Found)

cout<<"Record for modification does not exist";

File.close();

}

If the function Modify() is supposed to modify a record in file BOOK.DAT with the values of Book NEW passed to its argument, write the appropriate statement for Missing Statement using seekp() or seekg(), whichever needed, in the above code that would write the modified record at its proper place.

1 Answer

0 votes
by (61.3k points)
selected by
 
Best answer

File.seekg(-1*sizeof(NEW),ios::cur);

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...