Write a program to perform concatenation operation on Array.
/* Program for concatenate of elements. */
#include<stdio.h>
#include<conio.h>
void conate (int[], int[], int, int); // function declaration.
main()
{
int a[100],b[100],i,size1,size2;
/* inputting size of an array from user.*/
printf ("Enter the size of first array = ");
{
scanf ("%d",&size1);
}
/* inputting elemnts in first array. */
printf ("Enter %d elements in first array:- \n",size1);
for (i=0;i<size1;i++)
{
scanf ("%d",&a[i]);
}
/* inputting size of an array from user.*/
printf ("Enter the size of second array = ");
{
scanf ("%d",&size2);
}
/* inputting elemnts in second array. */
printf ("Enter %d elements in second array:- \n",size2);
for (i=0;i<size2;i++)
{
scanf ("%d",&b[i]);
}
conate (a,b,size1,size2); //calling the merge function.
/* Printing outputs of concatenated elemnts in array. */
printf ("After concatenation elemnts of array:- \n");
for (i=0;i<size1+size2;i++)
{
printf ("%d\t",a[i]);
}
}
void conate(int x[], int y[], int ne1, int ne2)
{
int i;
for (i=0; i<ne2;i++)
{
x[ne1++] = y[i];
}
}
0 Comments
Thank You ! For your love