Practical 2
Practical 2
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>
int stack[MAX];
int top=-1;
if (top>=MAX-1)
else
top++;
stack[top]=value;
void pop()
if (top<=-1)
{
else
top--;
void display()
if (top==-1)
cout<<"Stack is Empty.."<<endl;
else
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;
cin>>choice;
switch(choice)
case 1:
cin>>value;
push(value);
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
break;
default:
while(choice!=4);
return 0;
Output :