#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],b[10],c[50],n1,n2,n3,i,j;
printf("Enter Size of first Array\n");
scanf("%d",&n1);
printf("Enter %d value\n",n1);
for(i=0;i<n1;i++)
{
scanf("%d",&a[i]);
}
printf("Enter size of Second Array\n");
scanf("%d",&n2);
printf("Enter %d value\n",n2);
for(i=0;i<n2;i++)
{
scanf("%d",&b[i]);
}
n3=n1+n2;
for(i=0;i<n3;i++)
{
if(i<n1)
{
c[i]=a[i];
}
else
{
for(j=0;j<n2;j++)
{
c[i]=b[j];
i++;
}
}
}
printf("\nArray After merging are:\n");
for(i=0;i<n3;i++)
{
printf("\n%d",c[i]);
}
getch();
}
#include<conio.h>
void main()
{
int a[10],b[10],c[50],n1,n2,n3,i,j;
printf("Enter Size of first Array\n");
scanf("%d",&n1);
printf("Enter %d value\n",n1);
for(i=0;i<n1;i++)
{
scanf("%d",&a[i]);
}
printf("Enter size of Second Array\n");
scanf("%d",&n2);
printf("Enter %d value\n",n2);
for(i=0;i<n2;i++)
{
scanf("%d",&b[i]);
}
n3=n1+n2;
for(i=0;i<n3;i++)
{
if(i<n1)
{
c[i]=a[i];
}
else
{
for(j=0;j<n2;j++)
{
c[i]=b[j];
i++;
}
}
}
printf("\nArray After merging are:\n");
for(i=0;i<n3;i++)
{
printf("\n%d",c[i]);
}
getch();
}
No comments:
Post a Comment