program-
#include< stdio.h>
#include< conio.h>
#define max 50
int stack1[max],top1=-1;
int stack2[max],top2=-1;
int temp[max],t=-1;
void create()
{
char ch;
do
{
top1++;
printf("Enter Number\n");
scanf("%d",&stack1[top1]);
printf("Continue(y/n)\n");
ch=getch();
}while(ch=='y');
}
void traverse1()
{
int i;
printf("First Stack is :\n");
for(i=top1;i>=0;i--){
printf("%d ",stack1[i]);
}
}
void traverse2()
{
int i;
printf("Second Stack is :\n");
for(i=top2;i>=0;i--)
{
printf("%d ",stack2[i]);
}
}
void copy()
{
int i;
for(i=top1;i>=0;i--)
{
t++;
temp[t]=stack1[i];
}
for(i=t;i>=0;i--)
{
top2++;
stack2[top2]=temp[i];
}
}
void main()
{
clrscr();
create();
traverse1();
copy();
traverse2();
getch();
}
Enter Number
2
Continue(y/n)
Enter Number
1
Continue(y/n)
Enter Number
9
Continue(y/n)
Enter Number
3
Continue(y/n)
Enter Number
6
Continue(y/n)
First stack is :
6 3 9 1 2
Second Stack is :
6 3 9 1 2