write a program in c to merge two array
Answers were Sorted based on User's Feedback
Answer / priti rachana
#include<stdio.h>
#include<conio.h>
void main()
{
int p,q,m,n,c;
int a1[100],a2[100],a3[100];
puts("enter the number of elements of the 1st sorted array");
scanf("%d",&p);
puts("enter number ofthe 1st sorted array");
for(m=0;<=p-1;m++)
scanf("%d",&a1[m]);
puts("enter number of element of the 2nd sorted array");
scanf("%d",&q);
puts(enter element of the 2nd sorted array");
for(n=0;n<=q-1;n++)
scanf("%d",&a2[n]);
c=0;
m=0;
n=0;
while((m<p)&&(n<q))
{
if(a1[m]<=a2[n])
a3[c]=a1[m++];
else
a3[c]=a2[n++];
c++;
}
while(m<p)
{
a3[c]=a2[n];
c++;
n++;
}
puts("merged array in asending order");
for(m=0;m<=c-1;m++)
printf("%d\n",a3[m]);
}
puts("enter the number of elements in the 2nd sorted arra array");
scanf("%d",&q);
| Is This Answer Correct ? | 10 Yes | 4 No |
Answer / ashok kannan
#include<stdio.h>
void main()
{
int a[]={1,1,2,3,4,5},b[]={2,3,4,5,6};
int i,j;
for(i=0;a[i]!='\0';i++);
for(j=0;b[j]!='\0';j++)
{
a[i]=b[j];
i++;
}
for(i=0;a[i]!='\0';i++)
printf("%d",a[i]);
}
| Is This Answer Correct ? | 14 Yes | 29 No |
main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?
main() { int i=5,j=6,z; printf("%d",i+++j); }
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"
x=2 y=3 z=2 x++ + y++; printf("%d%d" x,y);
How we print the table of 3 using for loop in c programing?
How we will connect multiple client ? (without using fork,thread)
Link list in reverse order.
Which version do you prefer of the following two, 1) printf(ā%sā,str); // or the more curt one 2) printf(str);
why java is platform independent?
#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }
Is the following code legal? struct a { int x; struct a b; }