/*write a program for concatenation of two string using stack*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int n,m,i,top=0;
char str1[20],str2[20],stack[40];
clrscr();
printf("\nenter the first string:-");
gets(str1);
printf("\nenter the second string:-");
gets(str2);
strcat(str1,str2);
n=strlen(str1);
i=0;
n--;
while(n>=0)
{
stack[i]=str1[n];
i++;
n--;
}
i--;
printf("\nthe concatenation of two string is :\n");
for(top=i;top>=0;top--)
{
flushall();
printf("%c",stack[top]);
}
getch();
}
No comments:
Post a Comment