1.using an array of size 10, implement the PUSH and POP operations of the stack. NB: Let your TOP and BOTTOM be -1 when that STACK is EMPTY
2. Convert your algorithm above into a c++ code
1
Expert's answer
2013-05-01T09:05:19-0400
//1.using an array of size 10, implement the PUSH and POP operations of //the stack. NB: Let your TOP and BOTTOM be -1 when that STACK is EMPTY //2. Convert your algorithm above into a c++ code
# include <iostream>
using namespace std;
class stck{
int ar[10]; int ptr; public: stck(){ptr=-1;} void push(int val){ if (ptr == 8) cout<<"Stack is full!\n"; ptr++;ar[ptr] = val;} void pop(){if (ptr == -1) cout<<"Stack is Empty!\n"; else ptr--;} };
int main(){ stck s; s.push(1); s.pop(); s.pop(); for (int i=0;i<11;i++) s.push(1);
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment