C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
1
Reply
Push and pop method in stack and queue.
SURAJ KSHIRSAGAR
6y
545
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
#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
SURAJ KSHIRSAGAR
6y
0
Message