Sample Input: The new item to be pushed into the array.
array data: 1,2,3,4,5
pushing data:6
Sample output: A stack newly pushed
output:6,5,4,3,2,1
--------------------------------------------------
--------------------------------------------------
//LIFO=Last In First Out
-------------------------------------------
------------------------------------------
#include<stdio.h>
int main()
{
int a[9],n=10,i,e,l,t;
printf("\nEnter top no of elements :");
scanf("%d", &t);
if(t>=n)
{
printf("Stack is full");
}
else
{
printf("\nEnter inserted elements :");
scanf("%d", &e);
printf("\nEnter array data :\n");
for(i=0;i<=t;i++)
{
scanf("%d", &a[i]);
}
t=t+1;
a[t]=e;
for(i=0;i<=t;i++)
{
printf(" After pushed new Stack is:%d\n", a[i]);
}
}
return 0;
}
(By:shahimtiyaj)
0 comments:
একটি মন্তব্য পোস্ট করুন