Stack
Stack
Stack
A stack is a collection of items of the same type. Stack follows the Last In First Out (LIFO)
fashion where the last element entered is the first one to be popped out. In stacks, the
insertion and deletion of elements happen only at one endpoint of it.
Operations performed on Stacks
The table shows the basic operations served by the Stack:
Programming Language: C
IDE: VS Code
.
Source Code:
#include <stdio.h>
#include <process.h>
#include <stdlib.h>
printf("\nStack is empty!!");
}
else
{
printf("\nStack is...\n");
for (i = top; i >= 0; --i)
printf("%d\n", stack[i]);
}
}
Output:
.