Remember to checkout the Codesnip below to review the C++ code yourself! Feel free to copy the code, but I ask that you please provide credit if you leave the code unchanged when you use it.
//Programmer: Nazmus //Program: Using the Stack Library //Website: EasyProgramming.net #include<iostream> #include<stack> #include<string> using namespace std; int main() { stack<int> name; int n; char quest; cout << "Do you want to enter data (Y/N)? "; cin >> quest; while(quest=='Y' || quest=='y') { cout << "Please enter name: "; cin >> n; name.push(n); cout << "Do you want to enter data (Y/N)? "; cin >> quest; } cout << "\nThe total size of your stack is "<< name.size() << endl; cout << "\nThese are the values of your stack:\n\n"; while(!name.empty()) { cout << name.top() << endl; name.pop(); } system("pause"); }