Sunday, July 4, 2010

PROGRAM TO APPEND TWO ARRAYS(DS)

Buzz It
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char a[25],b[25],c[25],i,j,m,n,x=0;
clrscr();
cout<<"Enter the first string\n";
gets(a);
cout<<"Enter the second string\n";
gets(b);
m=strlen(a);
n=strlen(b);
for(i=0;i<m;i++)
c[i]=a[i];
for(j=i;j<(m+n);j++)
{
c[j]=b[x];
x++;
}
cout<<"The appended array is \n";
for(i=0;i<(m+n);i++)
cout<<c[i];
getch();
}

OUTPUT:
Enter the first string
farook
Enter the second string
college
The appended array is
farookcollege

0 comments:

Post a Comment