1.Write a C++ program to create a class called QUEUE with member functions to add an element and to delete an element from the queue. Display the contents of the queue after every operation.
2.A bookshop maintains the inventory of books that are being sold at the shop. The list has details like author, title, price, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displays a suitable message if it is not available. If it is available, the system displays the book details and requests for the number of copies required. If the copies are available, the total cost of the copies requested is displayed; otherwise the message ‘copies not in stock’ is displayed. Design a system using a class called BOOKS with suitable member functions and constructors. Use new operator in constructors to allocate required memory space.
C++ problems!!!!!!!!!!????? plz help me for these 2 problems?
class Q{
int rear=-1,front=-1;
int que[10];
int max=10;
void addEle(int element)
{
if (rear==max-1)
{
cout %26lt;%26lt;"Overflow";
return ;
}
if ( rear==-1)
front=rear=0;
else
rear++;
q[rear]=element;
cout %26lt;%26lt;"Element added"%26lt;%26lt;element;
}
void delet()
{
if (front==-1)
{
cout%26lt;%26lt;"underflow";
return ;
}
if ( front==rear)
front=rear= - 1 ;
else
front ++;
}
};
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment