Posts

Showing posts from March 15, 2018

Data Structure Lab 5

Image
#include<iostream> #define MAX 5 using namespace std; int STACK[MAX],TOP; //stack initialization void initStack(){     TOP=-1; } //check it is empty or not int isEmpty(){     if(TOP==-1)         return 1;     else         return 0; } //check stack is full or not int isFull(){     if(TOP==MAX-1)         return 1;     else           return 0; } void push(int num){     if(isFull()){         cout<<"STACK is FULL."<<endl;         return;     }     ++TOP;     STACK[TOP]=num;     cout<<num<<" has been inserted."<<endl; } void display(){     int i;     if(isEmpty()){         cout<<"STACK is EMPTY."<<endl;         return; ...