Answer to Question #242473 in C++ for zoyi

Question #242473

Write a function in C++ to insert a circular Queue containing

Players information (represented with the help of array of structure PLAYER).

Consider following definition of Node

struct PLAYER

{

int PID;

char Pname[20];

NODE* Next;

};


1
Expert's answer
2021-09-26T18:53:46-0400
#include<iostream>
using namespace std;


struct PLAYER


{


int PID;


char Pname[20];


PLAYER* Next;


};


void insert(PLAYER p[], int front, int rear, int max)
{
if((rear=max-1 && front ==0)||(front == rear +1))
{
cout<<"Circular Queue is full"; 
exit(0);
}
else if(front == -1 && rear == -1)
{
front = rear = 0;
}
else if(rear = max -1 && front >0)
{
rear = 0;
}
else
rear = rear+1; 
cout<<"Enter Player Id  and name\n"; 
cin>>p[rear].PID; 
gets(p[rear].Pname);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS