Computer Science, asked by cataloncamille9, 3 months ago

Write a C++ program to implement stack data structure with push and pop operation.

Answers

Answered by parvati1527
3

Answer:

The code snippet for this is as follows.

void push(int val) { if(top>=n-1) cout<<"Stack Overflow"<<endl; else { top++; stack[top]=val; } } ...

void pop() { if(top<=-1) cout<<"Stack Underflow"<<endl; else { cout<<"The popped element is "<< stack[top] <<endl; top--; } }

Similar questions