answersLogoWhite

0

Wap to merge two arrays using c?

Updated: 8/11/2023
User Avatar

Wiki User

12y ago

Best Answer

#include<stdio.h>

void main()

{

int a[5],b[5];

int c[10];

int i,j,temp,k;

printf("\n enter the elements of array A:=\n");

for(i=0;i<5;i++)

scanf("%d",&a[i]);

printf("\n enter the elements of array B:=\n");

for(i=0;i<5;i++)

scanf("%d",&b[i]);

for(i=1;i<5;i++)

{

for(j=0;j<5-i;j++)

{

if(a[j]>a[j+1])

{

temp=a[j];

a[j]=a[j+1];

a[j+1]=temp;

}

}

for(j=0;j<5-i;j++)

{

if(b[j]>b[j+1])

{

temp=b[j];

b[j]=b[j+1];

b[j+1]=temp;

}

}

}

printf("\n the elements of the array A:=\n");

for(i=0;i<5;i++)

printf("%d\t",a[i]);

printf("\n the elements of the array B:=\n");

for(i=0;i<5;i++)

printf("%d\t",b[i]);

i=0,j=0,k=0;

while(i<5&&j<5)

{

if(a[i]>b[j])

c[k++]=b[j++];

if(a[i]<b[j])

c[k++]=a[i++];

}

if(i<5&&j==5)

while(i<5)

c[k++]=a[i++];

if(i==5&&j<5)

while(j<5)

c[k++]=b[j++];

printf("\n the elements of the sorted merged array C:=\n");

for(i=0;i<10;i++)

printf("%d\t",c[i]);

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

#include <stdio.h>

int main ()

{

int a[10],b[10],c[20];

int k,i,j;

i=0;

printf("Please enter first 10 digits: ");

while (i<10)

{

scanf("%d", &a[i]);

i++;

}

printf("Please enter second 10 digits: ");

k=0;

while (k<10)

{

scanf("c%d",&b[k]);

k++;

}

j=0;

while (j<10)

{

c[j]=a[i];

j++;

}

while (j<20)

{

c[j]=b[k];

j++;

}

j=0;

while(j<20)

{

printf("%d\n", c[j]);

}

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

#include<stdio.h>

void main()

{

int a[10],b[10],c[20],i,n

printf("enter the no of element in the array a[10],b[10]");

scanf("%d",&n);

printf("enter the element in the array a[10],b[10]");

scanf("%d%d",&a[i],&b[i]) ;

for(i=0;i<=10;i++)

{

c[i]=a[i]+b[i];

}

for(i=0;i<=10;i++)

{

printf("the array is %d",c[i]);

}

}

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

#include<stdio.h> main() { printf("\n I am newer to C language"); }

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

iiljp'

kpljop]\\

nkij

\nhj\

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

you need to use ar3=*(ar1)+*(ar2)

where ar3 is sum array while ar1 and ar2 are input array.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

jjk,

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Wap to merge two arrays using c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the use of auxiliary array in merge sort?

In merge sort the whole is divided into two sub arrays. (This way of solving problem is called Divide and conquer algorithm) These sub arrays are called auxiliary arrays. First an array A is divided into two auxiliary arrays A1 and A2. Now these auxiliary arrays are further divided until we reach a stage with an auxiliary array of 2 elements. These 2 elements are arranged in incremental order and merged with the previous divided arrays. So we can say that auxiliary array is used to implement the basic principle of merge sort.


Given two arrays A and B Array?

distinguish extra element in two arrays


How do you find the difference between two arrays in Java?

for arrays you can list the different arrays and what attributes that you give to them.


Can ragged arrays created by using java?

I assume you mean that you have a number of rows, and that not all rows have the same number of "cells". Yes, in Java a two-dimensional array is implemented as an array of arrays (each item in the top-level array is, in itself, an array); a 3-dimensional array is an array of arrays of arrays, etc.; and there is no rule stating that all secondary (etc.) arrays must have the same number of elements.


Name two smaller arrays you can use to find the product of 8x6?

name two smaller arrays you can use to find the product


How do you merge two small businesses?

The way that you can merge two businesses is that the two business owners need to agree on a merge and its price. This must then be taken up with the government. The Government will then agree or disagree on the whole merge. GCSE BUSINESS ANSWER There are two types of merge in business 1. Friendly 2. Hostile


What is the benefits of using cache in wap?

WAP devices generally cache WML checks. This is to reduce the time that is wasted in trying to reload a page that has been loaded earlier. However for dynamic content this is not a good feature- the user may be reading some state information from the cache. Two uses:- Caching by proxy servers caching by wap devices Radha M.Sc(IT)


How do you get difference between two or more arrays in PHP?

The inherit function `array_dif($arrayOne, $arrayTwo, $arrayThree, ...)` is likely what you're looking for. It compares two or more arrays, and returns an array of values that are unique among the arrays.


What is it called when two tornadoes merge?

When two tornadoes merge, it is just called merging; there is no special term.


How do you swap two arrays in c plus plus using string?

You can't. While a string is a character array, an array is not necessarily a string. Treating arrays as if they were strings simply to swap them is madness. The correct way to physically swap arrays A and B is to copy A to a new array, C, then copy B to A, then C to B. If the arrays are the same size this is not a problem. If they are different sizes, you can only swap them if they are dynamic (not static). This means you must reallocate them. To speed up the process, copy the smallest array to C, first. A much better approach would be to point at the two arrays and swap the pointers instead.


What two genres of music did Miles Davis want to merge?

He wanted to merge rock and jazz.


Write a program using iostreams to take as input two multi-dimensional arrays and print their sum as output Matrix Addition in Matrix format?

http://www.assignmentsclub.com/