Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

C++ Exam Worksheet-1 Class 12

STACK & QUEUE


Write a function in C++ to insert in a static circular Queue containing Players
information(represented with the help of array of structure PLAYER
struct PLAYER
{
int PID; char Pname[20]
};
Write a function in C++ to insert in a static Stack containing Players information(represented with
the help of array of structure PLAYER
struct PLAYER
{
int PID; char Pname[20]
};
Write a function in QUEINS() in C++ to delete a dynamically allocated Queue containing nodes of
following given structure:
Assume the following definition of MYNODE for the same:
struct NODE
{ int PID; char Pname[20];NODE *Next
};
Write a function in C++ to insert an element into a dynamically allocated Queue where each
node contains a name (of type string) as data.
Assume the following definition of THENODE for the same.
struct THENODE
{
char Name[20]; THENODE *Link;
};
Define member function QInsert( ) to insert and QDel( ) to delete nodes of a linked list
implemented class Queue having the following Definitions:
Struct Node
{ char name[20];
int age;
Node *Link;
};
class Queue
{ Node *Rear, *Front;
public:
Queue( ) { Rear=NULL; Front = NULL}
void QInsert( );
vinodsrivastava.com vinsri76@yahoo.com +965-69300304 Page 1
C++ Exam Worksheet-1 Class 12

void QDel( );
};
Write the definition of a member function PUSH( ) in C++, to add a new book in a dynamic stack of
BOOKS considering the following code is already included in the program
struct BOOKS
{ char ISBN[20], TITLE[80]; BOOKS *Link;
};
class STACK
{ BOOKS *Top;
public:
STACK(){Top=NULL;}
void PUSH();
void POP();
~STACK();
}
Write the definition of a member function POP( ) in C++, to delete a book in a dynamic stack of
BOOKS considering the following code is already included in the program
struct BOOKS
{ char ISBN[20], TITLE[80]; BOOKS *Link;
};
class STACK
{ BOOKS *Top;
public:
STACK(){Top=NULL;}
void PUSH();
void POP();
~STACK();
}
Write the definition of a member function push() for a class Library in C++ to insert a book
information in a dynamically allocated stack of books considering the following code is already
written as a part of the program:
struct book
{
int bookid;
char bookname[20];
book *next;
};
class Library
{
book *top;
public:
Library()
{
top=NULL;
}
void push();
void pop();
void disp();
~Library();
};

vinodsrivastava.com vinsri76@yahoo.com +965-69300304 Page 2


C++ Exam Worksheet-1 Class 12

vinodsrivastava.com vinsri76@yahoo.com +965-69300304 Page 3

You might also like