How a new element can be added or pushed in a stack?



How a new element can be added or pushed in a stack?..

Answer / Vipin Gautam

A new element can be added to a stack using the push() function in STL (Standard Template Library). This function appends an element onto the top of the stack, increasing its size by 1. Example: n```n#include <stack>nstack<int> s; // creating a stack of integersns.push(5); // adding the number 5 to the stackn```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What are the basics of classifying different storage types, why?

2 Answers   Astergate, Symphony,


What is virtual destructor ans explain its use?

1 Answers  


When can I use a forward declaration?

1 Answers  


Which bitwise operator is used to check whether a particular bit is on or off?

1 Answers  


Explain the difference between static and dynamic binding of functions?

1 Answers  


an integer constant must have atleast one a) character b) digit c) decimal point

1 Answers  


What is low level language in simple words?

1 Answers  


What is the use of this pointer in c++?

1 Answers  


Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

1 Answers  


Reverse the Linked List. Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL

1 Answers  


How does the copy constructor differ from the assignment operator (=)?

1 Answers  


What are smart pointers?

4 Answers  


Categories