MENU
Question -

Given the binary file CAR.Dat, containing . records of the following class CAR type:

class CAR
 {
 int C_No;
 char C_Name[20];
 float Mileage;
 public :
 void enter( )
 {
 cin>> C_No ; gets(C_Name) ; cin >>Mileage;
 }
 void display( )
 {



Answer -

void CARSearch ()
 {
 fstream FIL;
 FIL.open("CAR.DAT" , ios::binary|ios::in);
 CAR C;
 int Found = 0;
 while(FIL.read((char*)&C,sizeof(C)))
 {
 if ((C.RETURN_Mileage( )>100) &&
 (C.RETURN_Mileage( ) < 150) )
 {
 C.display();
 Found++;
 }
 }
 if (Found==0)
 cout<<"Sorry! No car found with mileage between 100 to 150";
 FIL.close () ;
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×