SURAJ KSHIRSAGAR
Push and pop method in stack and queue.
By SURAJ KSHIRSAGAR in .NET on Mar 04 2019
  • SURAJ KSHIRSAGAR
    Mar, 2019 4

    #include #include using namespace std; int main() { // Empty stack stack mystack; mystack.push(0); mystack.push(1); mystack.push(2); // Printing content of stack while (!mystack.empty()) { cout << ' ' << mystack.top(); mystack.pop(); } } O/P= 2 1 0 Note that output is printed on the basis of LIFO propertyEg Input : mystack = 0, 1, 2mystack.pop(); Output : 0, 1Input : mystack = 0, 1, 2, 3, 4, 5mystack.pop(); Output : 0, 1, 2, 3, 4

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS