Fewpal
0 votes
18 views
in Computer by (52.3k points)
closed by

Find the output of the following C++ code considering that the binary file sp.dat already exists on the hard disk with 2 records in it. 

class sports 

int id;

char sname[20]; 

char coach[20];

public:

void entry();

void show(); 

void writing(); 

void reading(); 

}s; 

void sports::reading() 

ifstream i;

i.open("sp.dat");

while 

{

i.read((char*)&s, sizeof(s)); 

if(i.eof()) break; 

else 

cout<<"\n" <<i.tellg();

i.close(); 

}

void main() 

{

s.reading(); 

}

1 Answer

+1 vote
by (47.6k points)
selected by
 
Best answer

Output

42

84

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

...