Professional Documents
Culture Documents
Module 4
Module 4
JOANN E. FAUSTO
BSIT2A
SELF-CHECK
Q-1: Given the following sequence of stack operations, what is
the top item on the stack when the sequence is complete? stack m;
m.push(5); m.push(12); m.pop(); m.push(27); cout << m.top();
A. 5
B. 12
C. 27
D. The stack is empty
Answer: C
SELF-CHECK
Answer: 10 3 5 * 16 4 - / +
Answer: 9
ziuqskeeg
#include <iostream>
#include <stack>
using namespace std;
// Function to print all elements which are greater than all
// elements present to their right
void find(int arr[], int n)
{
// create an empty stack
stack<int> stk;
ASSESSMENT TASK
int main()
{
int j = 14;
// Empty stack
stack<int> joann;
joann.push(8);
joann.push(14);
joann.push(18);
joann.push(3);
joann.push(11);
// stack becomes 8, 14, 18, 3, 11
bool isOperand(char c)
{
// If the character is a digit then it must
// be an operand
return isdigit(c);
}