ENTER TWO ARRAY AND MERGE IN 3RD ARRAY
In below code we Enter two array and merge in 3rd array#include<stdio.h>
#include<conio.h>
void merge_array(int a[],int b[]);
void main()
{
int a[10],b[10],i,n;
clrscr();
printf("ENTER ELEMENT IN 1ST ARRAY ");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf("ENTER ELEMENT IN 1ST ARRAY ");
for(i=0;i<10;i++)
{
scanf("%d",&b[i]);
}
merge_array(a,b);
getch();
}
void merge_array(int a[],int b[])
{
int c[20],i;
printf("\n\nELEMENT OF 1ST ARRAY");
for(i=0;i<10;i++)
{
printf(" %d",a[i]);
}
printf("\n\nELEMENT of 2ND ARRAY");
for(i=0;i<10;i++)
{
printf(" %d",b[i]);
}
printf("\n\nELEMENT OF ARRAY AFTER MERGE ");
for(i=0;i<10;i++)
{
c[i]=a[i];
}
for(i=0;i<10;i++)
{
c[i+10]=b[i];
}
for(i=0;i<20;i++)
{
printf(" %d",c[i]);
}
}
OUTPUT
No comments:
Post a Comment