Stack Implementation
Stack Implementation
Stack Implementation
Stack Algorithm:
}
printf("Enter Your Choice:");
scanf("%d",&c);
}
return 0;
}
int push( )
{
int o;
if(top==max-1)printf("Stack Is Full\n");
else
printf("Enter The Number Of Elements To Insert In Stack:");
scanf("%d",&o);
printf("Enter %d Elements:\n",o);
for(i=0;i<o;i++)
{
scanf("%d",&x);
s[++top]=x;
}
}
int pop()
{
if(top==-1)printf("Stack Is Underflow\n");
else
top--;
}
int display()
{
if(top==-1) printf("No Elements in Stack To Display");
else
printf("The Elements In Stack Are As Follows:\n");
for(i=top;i>=0;i--)
printf("\n%d",s[i]);
printf("\n");
}
Output:
Eg 1:
Welcome To Stack Operations:
1.Push
2.Pop
3.Display
Enter Your Choice:1
Enter The Number Of Elements To Insert In Stack:5
Enter 5 Elements:
441
484
529
576
625
Enter Your Choice:2
Enter Your Choice:3
The Elements In Stack Are As Follows:
576
529
484
441
Enter Your Choice:
Eg 2: