how to check whether a stack is empty or full in c code example
Example 1: sum of stack c++
stack<int> si;
int sum = 0;
stack<int> tsi(si);
while (!tsi.empty()) {
sum += tsi.top();
tsi.pop();
}
Example 2: check an stack is empty c++
std::stack <int> st;
if(st.empty())
std::cout << "stack is empty";