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

Write the definition of a member function Ins_Player() for a class CQUEUE in C++, to add a Player in a statically allocated circular queue of PLAYERs considering the following code is already written as a part of the program:

struct Player

{

long Pid;

char Pname[20];

};

const int size=10;

class CQUEUE

{

Player Ar[size];

int Front, Rear;

public:

CQUEUE( )

{

Front = -1;

Rear=-1;

}

void Ins_Player(); // To add player in a static circular queue

void Del_Player(); // To remove player from a static circular queue

void Show_Player(); // To display static circular queue

};

1 Answer

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

void CQUEUE : : Ins_Player( )

{

if((Front==0 && Rear==size-1) || (Front==Rear+1)

{

cout<< “Overflow”;

return;

}

else if(Rear = = -1)

{

Front=0;

Rear=0;

}

else if(Rear= =size-1)

{

Rear=0;

}

else

{

Rear++;

}

cout<< “Enter Player Id=”;

cin>>Ar[Rear].Pid;

cout<< “Enter Player Name=”;

gets(Ar[Rear].Pname);

}

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

...