Write The C++ Program To Implement The Program Development Using STL
Ex: No: 9 PROGRAM DEVELOPMENT USING STL
Aim:To write the c++ program to implement the program development using STL
Algorithm:
Step 1: Start the program.
Step 2: Declare the main function
Step 3: We can invoke the stack empty(),push(), pop() function like carry ordinary function.
Step 4: Then display the stack variables.
Step 5: Stop the program.
Program:
#include
#include "Stack.h"
using namespace std;
int main(){
Stack myStack;
if (myStack.empty())
cout<<"Stack is empty"<
else
cout<<"Stack is not empty"<
for (int i = 0; i < 10; i++)
myStack.push(i);
cout<<"The top of the Stack is: "<
if (myStack.empty())
cout<<"Stack is empty"<
else
cout<<"Stack is not empty"<
myStack.writeStack();
cout<
cout<
while (!myStack.empty())
myStack.pop();
if (myStack.empty())
cout<<"Stack is empty"<
else
cout<<"Stack is not empty"<
cout<<"The top of the Stack is: "<
return 0;
}
Output:
Stack is empty
the top of the Stack is: 9
Stack is not empty
9 8 7 6 5 4 3 2 1 0
My Stack size is: 10
Stack is empty
top (): Stack is empty
Result:
Thus the implementation of c ++ program for development of STL is executed and the output has been verified.
0 comments:
Post a Comment