The Total solution for NCERT class 6-12
Answer - 21 : -
Answer - 22 : -
Answer - 23 : -
Answer - 24 : -
float GetPrice () {return PRICE; }.Answer: Answer - 25 : - void COSTLY () { GIFTS G; ifstream fin ("GIFTS.DAT" , ios : : binary); while (fin.read( (char *)&G, sizeof (G))) { if (G.GetPrlce () >2000) G.View (); } fin. close ();ORAny other correct equivalent function definition Question - 26 : - Find the output of the following C++ code considering that the binary file MEMBER. DAT exists on the hard disk with records of 100 members:class MEMBER { int Mno; char Name [20]; public : void In (); void out (); }; void main () { fstream MF; MF.open (:MEMBER.DAT", ios :: binary |ios :: in); MEMBER M; MF.read ((char*) &M, sizeof (M)) ; MF.read ((char*)) &M, sizeof (M)); MF.read ((char*) &M, sizeof (M)); int POSITION = MF. tellg () / sizeof (M) ; Cout<<"PRESENT REOCRD :"< MF.close () ; } Answer - 26 : - PRESENT RECORD : 3 Question - 27 : - Write a definition for function Economic ( ) in C++ to read each record of a binary file ITEMS.DAT, find and display those items, which costs less than 2500. Assume that the file ITEMS. DAT is created with the help of objects of class ITEMS, which is defined below :class ITEMS { int ID; char GIFT [20] ; float cost ; public : void Get () { cin>>CODE,-gets (GIFT) ; cin>>cost; } void See () { COUt < } float GetCost 0 {return Cost;}. } ; Answer - 27 : - void Economic () { ITEMS I; ifstream fin (" ITEMS.DAT",ios:: binary); while (fin.read ((char *)&I,sizeof (I))) { if (I.GetCost ()<2500) I. See (); } fin. close (); }ORAny other correct equivalent function definition Question - 28 : - Write function definition for WORDABSTART () in C++ to read the content of a text file, JOY. TXT, and display all those words, which are starting with either ‘A’, ‘a’ or ‘B’, ‘b’.Example:If the content of the file JOY.TXT is as follows :I love to eat apples and bananas. I was travelling to Ahmedabad to buy some clothes.The function WORDABSTART() should display the following:apples bananas Ahmedabad buy Answer - 28 : - void WORDABSTART () { ifstream fil; fi1.open ("JOY.TXT"); char W[20]; fi1> >W; while(!fil.eof())//OR While(fil) { if(strlen(w)==4) cout< >W; } fil.close ();//Ignore } Question - 29 : - Write a definition for function OFFER() in C+ + to read each object of a binary file OFFER.DAT, find and display details of those ITEMS, which has status as “ON OFFER”. Assume that the file OFFER.DAT is created with the help of objects of class ITEMS, which is defined below:class ITEMS { int ID;char Item[20];Status[20]; float Price; public: void GetonstockO { cin>>ID;gets(Item);gets(Status); cin>>Price; } void view() { cout< char*IStatus(){return Status}. }; Answer - 29 : - void OFFER () { ITEMS; ifstream fin; fin.open("OFFER.DAT",ios::binary); while(fin.read(char*)&G size of(G)) { if strcmp (G.Get status(),"ON OFFER")==0) G.view(); } fin.close()///Ignore} Question - 30 : - 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( ) { cout< cout< } int RETURN_Mileage( ) { return Mileage; } };Write a function in C++, that would read contents from the file CAR.DAT and display the details of car with mileage between 100 to 150. Answer - 30 : - 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 () ; } PreviousNext Free - Previous Years Question Papers Any questions? Ask us! NodeJS Interview Questions Answers ASP.Net Interview Questions Answers Interview Questions Answers × Subscribe Now!
Answer - 25 : -
Answer - 26 : -
Answer - 27 : -
Answer - 28 : -
Answer - 29 : -
Answer - 30 : -