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 |
int i; main(){ int t; for ( t=4;scanf("%d",&i)-t;printf("%d\n",i)) printf("%d--",t--); } // If the inputs are 0,1,2,3 find the o/p
main() { int i=10; void pascal f(int,int,int); f(i++,i++,i++); printf(" %d",i); } void pascal f(integer :i,integer:j,integer :k) { write(i,j,k); }
how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!
#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }
can u give me the c codings for converting a string into the hexa decimal form......
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
Cluster head selection in Wireless Sensor Network using C programming language.
What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }
main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?
how to test pierrot divisor
main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }
int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }