3 Marks Questions

 

  1. Given a binary file SPORTS.DAT, containing records of the following structure type:

struct Sports

{ char Event[20];

char Participant[10][30];

};

Write a function in C++ that would read contents from the file SPORTS.DAT and creates a file named

ATHLETIC.DAT copying only those records from SPORTS.DAT where the event name is “Athletics”.

Read more

 

 

  1. Write a function in C++ to count the words to and the present in a text file “POEM.TXT”.

[Note. that the words “to’ and “the” are complete words.]

Read more

 

  1. Write a function in C++ to search and display details. of all trains, whose destination is “Delhi” from a binary file

TRAIN.DAT”. Assuming the binary file is containing the objects of the following class.

class TRAIN

{

int Tno; // Train Number

char From[20]; // Train Starting Point

char To[20]; // Train Destination

public:

char* GetFrom (){return From;}

char* GetTo (){return To;}

void Input () {cin>>Tno;gets(From);gets(To);}

void Show () {cout<<Tno<<:<<From<<:<<To<<endl;}

};

 Read more

 

  1. Given a binary file TELEPHON.DAT, containing records of the following class Directory:
Read more

 

  1. Write a function COPYABC() in C++, that would copy all those records having AreaCode as “123” from

TELEPHONE.DAT to TELEBACK.DAT.

Read more

 

  1. Given a binary file CONSUMER.DAT, containing records of the following structure type

class Consumer

{ char C_Name[20];

char C_Address[30];

char Area[25];

char C_Phone_No[15];

public:

void Ledger();

void Disp();

int checkCode(char AC[])

{ return strcmp(Area,AC); }

};

Write a function COPYAREA() in C++, that would copy all those records having Area as “SOUTH” from

CONSUMER.DAT to BACKUP.DAT.

Read more

 

  1. Given a binary file GAME.DAT, containing records of the following structure type

struct Game

{ char GameName[20];

char Participant[10][30];

};

Write a function in C++ that would read contents from the file GAME.DAT and creates a file named BASKET.DAT

copying only those records from GAME.DAT where the event name is “Basket Ball”.

Read more  

 

  1. Write a function in C++ to read and display the detail of all the users whose status is ‘A’ (i.e. Active) from a binary file “USER.DAT”. Assuming the binary file “USER.DAT” is containing objects of class USER, which is defined as follows:

class USER{

int Uid; // User Id

char Uname[20]; // User Name

char Status; // User Type: A Active I Inactive public:

public:

void Register( ); // Function to enter the content

void show( ); // Function to display all data members

char Getstatus( )

{ return Status; }

};

Read more  

 

  1. Write a function in C++ to search for a laptop from a binary file “LAPTOP.DAT” containing the objects of class

LAPTOP (as defined below). The user should enter the Model No and the function should search and display the

details of the laptop.

class LAPTOP{

long ModelNo;

float RAM,HDD;

char Details[120];

public:

void StockEnter()

{ cin>>Modelno>>RAM>>HDD;

gets(Details);

}

void StockDisplay()

{ cout<<ModelNo<<RAM<<HDD<<Details<<endl;

}

long ReturnModelNo()

{ return ModelNo; }

};

Read more

 

  1. Write a function in C++ to count the no of “Me” or “My” words present in a text file “DIARY.TXT”.

If the file “DIARY.TXT” content is as follows:

My first book was Me and My family. It gave me chance to be known the world.

The output of the function should be

Count of Me/My in file : 4

Read more
Rate Us
error: Content is protected !!