Hi, I am Aman Kumar pursuing BCA II. I have decided to write what i learn daily.
I request you to please go through this program and feel free to write me if you have any advice/suggestions for me at 2022amankumar@gmail.com
Source Code for Stack using Linked list.
#include<iostream>
using namespace std;
struct Node{
int data;
Node* link;
};
class Stack{
Node* top=NULL;
public:
void Push(int x)
{
Node *temp=new Node;
temp->data=x;
temp->link=top;
top=tmp;
}
void Pop()
{
Node* temp;
if(top==NULL)
return;
temp=top;
top=top->link;
delete top;
}
int Top()
{
return top->data;
}
float isEmpty()
{
if(top==NULL)
return true;
else
return false;
}
};
Comments
Post a Comment