# Answer to Question #22654 in C++ for rodea embradura

Question #22654

create a program that will perform the following task:

-pop(s) { remove an item/element from the top of stack }

-push(s,i) { to add an element to the top of the stack }

-empty(s) { determine if the stack is empty or not }

-stack top(s) { determine the top element of the stack }

-pop(s) { remove an item/element from the top of stack }

-push(s,i) { to add an element to the top of the stack }

-empty(s) { determine if the stack is empty or not }

-stack top(s) { determine the top element of the stack }

Expert's answer

#include <iostream>

using namespace std;

class stack{

int m[100];

int head;

public:

stack(){head=-1;}

void push(int a){

head++;

m[head] = a;

}

bool pop(){

if (head >= 0){

head--;

return true;

}

else return false;

}

bool empty(){

if (head >= 0 ) return true;

else return false;

}

int stackTop(){return m[head];}

};

int main(){

return 0;

}

using namespace std;

class stack{

int m[100];

int head;

public:

stack(){head=-1;}

void push(int a){

head++;

m[head] = a;

}

bool pop(){

if (head >= 0){

head--;

return true;

}

else return false;

}

bool empty(){

if (head >= 0 ) return true;

else return false;

}

int stackTop(){return m[head];}

};

int main(){

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment