0% found this document useful (0 votes)
29 views4 pages

Practical 2

Practice 2

Uploaded by

amarkamthe0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

Practical 2

Practice 2

Uploaded by

amarkamthe0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name : Arya Kiran Dandnaik

Roll No : S511074

Division : A

Subject : DSA

Problem Statement : Implement stack as an abstract datatype and using this ADT for conversion of
infix to postfix, evolution of postfix and prefix expression

Input Of Problem :

#include<iostream>

using namespace std;

const int MAX =15;

int stack[MAX];

int top=-1;

void push(int value)

if (top>=MAX-1)

cout<<"Stack is OVERFLOW.!! PLZZ TRY AGAIN"<< endl;

else

top++;

stack[top]=value;

void pop()

if (top<=-1)
{

cout<<"Stack is UNDERFLOW.!! PLZZ TRY AGAIN"<< endl;

else

cout<<"Your Popped Element is :"<<stack[top]<<endl;

top--;

void display()

if (top==-1)

cout<<"Stack is Empty.."<<endl;

else

cout<<"Stack Element are..:";

for (int i=0;i<=top;i++)

cout<<stack[i]<<"";

cout<<endl;

int main()

int choice,value;

do

{
cout<<"1..PUSH"<<endl;

cout<<"2..POP"<<endl;

cout<<"3..DISPLAY"<<endl;

cout<<"4..EXIT"<<endl;

cout<<"Enter Your Choice For Performing Operation Which You Want.:"<<endl;

cin>>choice;

switch(choice)

case 1:

cout<<"Enter the value for push element in stack..:";

cin>>value;

push(value);

break;

case 2:

pop();

break;

case 3:

display();

break;

case 4:

cout<<"Exit from the Program.."<<endl;

break;

default:

cout<<"Invalid input.. plzz Try again.."<<endl;

while(choice!=4);
return 0;

Output :

You might also like