basic intro of stack
Thu Sep 26 2024 09:28:26 GMT+0000 (Coordinated Universal Time)
Saved by
@E23CSEU1151
#include <iostream>
#include <stack>
using namespace std;
int main() {
stack <int > s; // creation
s.push(1); // putting vales
s.push(3);
s.pop(); // removing one value
cout << "elemenst at top " << s.top() << endl;
// printing top value
if(s.empty()) // checking
{
cout << "stack is empty " << endl;
}
else
{
cout << "stack is not empty " << endl;
}
return 0;
}
content_copyCOPY
Comments