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
2.2k views
in Computer by (71.3k points)

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(1)

{

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 (76.5k points)
selected by
 
Best answer

The output is:

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

...