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

Given a binary file STUDENT.DAT, containing records of the following class Student type

class Student

{  char S_Admno[10]; //Admissio number of student

char S_Name[30]; //Name of student

int Percentage; // Marks Percentage of student

 public:

void EnterData()

{  gets(S_Admno); gets(S_Name);

cin>>Percentage; }

void DisplayData()

{  cout<<setw(12)<<S_Admno;

cout<<setw(32)<<S_Name;

cout<<setw(3)<<Percentage<<endl;

}

int ReturnPercentage ()

{  return Percentage; }

};

Write a function in C++, that would read contents of file STUDENT.DAT and display the details of those Students whose Percentage is above 75.

1 Answer

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

void Dispmore75() {

ifstream fin;

fin.open("STUDENT.DAT",ios::in|ios::out|ios::binary);

Student A;

while(!fin.eof())

{

fin.read((char*)&A,sizeof(A));

if(A.ReturnPercentage()>75)

A.DisplayData();

}

fin.close();

}

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

...