Write a c program for Concatenation of two srings using stack.


#include

#include

#include

#include
 
void main()

{

int top=-1,i=0;

char s1[15],s2[15],con[30];

clrscr();

printf("\nEnter 1st String:");

gets(s1);

printf("\nEnter 2nd string:");

gets(s2);

while(s1[i]!=NULL)

{

top++;

con[top]=s1[i];

i++;

}

i=0;

while(s2[i]!=NULL)

{

top++;

con[top]=s2[i];

i++;

}

printf("\nAfter concatenation: \n");

for(i=0;i<=top;i++)

printf("%c",con[i]);

getch();

}


/*OUTPUT


Enter 1st String:Amit


Enter 2nd string:Sharma


After concatenation:

AmitSharma



Enter 1st String:Ganesh                                                        

                                                                               

Enter 2nd string:Verma


After concatenation:

GaneshVerma */
Write a c program for Concatenation of two srings using stack. Write a c program for Concatenation of two srings using stack. Reviewed by on November 16, 2013 Rating: 5
Powered by Blogger.