Implementation of Stack
Implementation of Stack
#include <stdio.h>
#include <conio.h>
struct Node
int data;
};
void push(int);
void pop();
void display();
void main()
clrscr();
while(1)
switch(choice)
scanf("%d", &data);
push(data);
break;
case 2: pop();
break;
case 3: display();
break;
case 4: exit(0);
newNode->data = data;
if(top == NULL)
newNode->next = NULL;
else
newNode->next = top;
top = newNode;
void pop()
if(top == NULL)
printf("\nStack is Empty!!!\n");
else
top = temp->next;
free(temp);
void display()
if (top == NULL)
printf("\nStack is Empty!!!\n");
else
printf("%d--->",temp->data);
printf("%d--->NULL",temp->data);
}
Output=