stack-programC--
stack-programC--
# include<iostream>
using namespace std;
const int n=10;
int top;
int Stack[n]; //Maximum size of Stack
// declaring all the function
void push(int x);
int pop();
bool isFull();
bool isEmpty();
void printStack();
// function to insert data into stack
void push(int x)
{
if (isFull()) cout << "Stack Overflow \n";
else
{
top = top + 1;
Stack[top] = x;
}
}
// function to remove data from the top of the stack
int pop()
{
int d;
if(isEmpty()) cout << "Stack Underflow \n";
else
{
d = Stack[top];
top = top -1;
return d;
}
}
// function to check if stack is full
bool isFull()
{
if(top >= n ) return true;
else return false;
}