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 }
1
Expert's answer
2013-01-23T09:52:59-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS