Question # 1: Write a program to input and PUSH 10 values into a stack. POP the values from stack and print only even values on the screen ?Question # 2: Write a program to input and PUSH 5 values into a stack. POP values from the stack one by one and calculate factorial of each item ?



Answer :

A program that can input 10 values and PUSH them onto a stack. POP the values from the stack and display just even values. The code in C++ 2#include <iostream>

#include <stack>

using namespace std;

int main()

{

   // declare a variable stack of type stack of integers

   stack<int> stack;

   // push 10 values 21-31 to the stack

   stack.push(21);

   stack.push(22);

   stack.push(23);

   stack.push(24);

   stack.push(25);

   stack.push(26);

   stack.push(28);

   stack.push(29);

   stack.push(30);

   stack.push(31);

   

   // while stack is not empty

   while (!stack.empty()) {

       // if the top element of the stack is even

       if (stack .top() % 2 == 0) {

           // then display the top element

           cout << ' ' << stack.top();

       }

       // pop each ||ut of the stack

       stack.pop();

   }

}

To learn more about stack

https://brainly.com/question/14257345

#SPJ4