Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <stack>
    using namespace std;
    int main ()
    {
    stack<int> StackData;
    StackData.push(25);
    StackData.push(45);
    StackData.top() -= 5;
    cout << StackData.top() << endl;
    return 0;
    }
    1. 45
    2. 25
    3. 5
    4. Compilation Error
    5. None of these
Correct Option: A

In this program, We used top option and this will return the reference to the next element.



Your comments will be displayed only after manual approval.