write a function in C++ to perform Push operation in a dynamically allocated stack containing real number
Answers
Answered by
0
Explanation:
struct NODE
{ char Name[20];
NODE *Link;
};
Solution:
class Queue
{
NODE *front,*rear;
public:
Queue( )
{ front = rear = NULL; }
void Insert( );
void Delete( );
void Display( );
};
void Queue::Insert( )
{
NODE *ptr;
ptr=new NODE;
if(ptr= = NULL)
{
cout<<”\nNo memory to create a new node….”;
exit(1);
}
cout<<”\nEnter the name….”;
gets(ptr → Name);
ptr→ Link=NULL;
if(rear= = NULL)
front=rear=ptr;
else
{
rear→Link=ptr;
rear=ptr;
}
}
Similar questions