Questions and Answers


  1. What do associate containers implement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Associative containers refer to a group of class templates in the standard library of the C++ programming language that implement ordered associative arrays.


  1. Which operator is used in priority queue?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    operator<



  1. In which context does the stack operates?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    A stack is a container where elements operate in a LIFO context, where elements are inserted (pushed) and removed (popped) from the end of the container.


  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. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

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



  1. What is the output of this program?
    #include <iostream>
    #include <stack>
    using namespace std;
    int main ()
    {
    stack<int> StackData;
    cout << (int) StackData.size();
    for (int k =0; k < 5; k++)
    {
    StackData.push(k);
    cout << " ";
    cout << (int) StackData.size() << " ";
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    In this program, We declared myints and not initialized in first option, So it’s value is 0 and on another, We are pushing 5 values, So it’s size is 5.