Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions DSA/DSA-CPP/Stacks/implementingstackusingarray.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <bits/stdc++.h>
using namespace std;

class Stack{
public:
int size;
int top;
int *arr;

int isempty(){
if(top==-1){
return 1;
}
return 0;
}
int isfull(){
if(top==size-1){
return 1;
}
return 0;
}
};

int main()
{
// Stack s;
// s.size=80;
// s.top=-1;
// s.arr=new int[s.size];

Stack *s=new Stack;
s->size=4;
s->top=-1;
s->arr=new int[s->size];

s->arr[++s->top]=4;
s->arr[++s->top]=5;
s->arr[++s->top]=8;
s->arr[++s->top]=9;

if(s->isempty()){
cout<<"The stack is empty";
}
else{
cout<<"The stack is not empty";
}

return 0;
}