55. WRITE A C PROGRAM TO APPEND TWO SINGLE DIMENSIONAL ARRAYS

/*C program to append two single dimensional arrays*/

#include<stdio.h>
#include<conio.h>
int main()
{
int a[50],b[50],c[100],n1,n2,i,j;
clrscr();
printf(“how many elements for a array\n”);
scanf(“%d”,&n1);
printf(“enter the values of a”);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
printf(“how many elements for b array\n”);
scanf(“%d”,&n2);
printf(“enter the values of b”);
for(j=0;j<n2;j++)
scanf(“%d”,n2);
printf(“result = ”);
for(i=0;i<n1;i++)
c[i]=a[i];
for(j=0;j<n2;j++)
{
c[i]=b[i];
i++;
}
for(i=0;i<n1+n2;i++)
printf(“%d”,c[i]);
getch();
return 0;
}

output

how many elements for a array2
enter the values of a1
2
how many elements for b array3
enter the values of b3
4
5
result = 1
2
3
4
5

Comments