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

Write a program to search the name and address of person having age more than 30 in the data list of persons. 

1 Answer

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

Assuming the file “employee.dat” is already existing in binary format.

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#include<fstream.h>

class employee { 

har name[20];

char address[20];

int age;

public:

void showdata()

{

cout<<"\nEmployee Name : ";

puts(name);

cout<<"\nEmployee Address : ";

puts( address);

}

int retage()

{

return age;

}

};

void search () {

employee emp;

ifstream ifs;

ifs.open("employee.dat",ios::binary); 

while(ifs.read((char*)&emp,sizeof(emp)))

{

if(emp.retage()>30)

emp.showdata();

}

ifs.close();

}

void main()

{

clrscr();

search();

getch();

}

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

...