write a program to input two integer arrays of n and m length respectively arranged in ascending order and print the third array of p length by merging the two arrays which should be in ascending order without using bubble sort or selection Sort
For example
First array. Second array
n=10. m=5
a[n]. b[m]
1. 2
3. 4
5. 6
7. 8
9. 10
11
13
15
17
19
Third array
p=m+n=10+5=15
c[p]
1
2
3
4
5
6
7
8
9
10
11
13
15
17
19
Answers
Answered by
0
1
2
int main () 3
{ 4
int i , arr [ 10 ], sum = 0 ; 5
6
printf ("Enter 10 elements:" ); 7
for(i =0 ; i <10 ;++ i ) 8
scanf ("%d" ,& arr [ i ]); 9
10
for(i =0 ; i <10 ;++ i ) 11
sum = sum + arr [ i ]; 12
printf ("Sum of numbers is:%d" , sum ); 13
14
return 0 ; 15
} 16
#include <iostream> 1
2
using namespace std ; 3
4
int main () 5
{ 6
int i , arr [ 10 ], sum = 0 ; 7
8
cout << "Enter 10 elements:" ; 9
for(i =0 ; i <10 ;++ i ) 10
cin >> arr [ i ]; 11
12
for(i =0 ; i <10 ;++ i ) 13
sum = sum + arr [ i ]; 14
cout << "Sum of numbers is:" << sum ; 15
16
return 0 ; 17
} 18
import java . util. Scanner ; 1
2
3
public class Example12 { 4
5
public static void main (String [] args ) { 6
7
int i , sum = 0 ; 8
int arr []=new int [ 10 ]; 9
10
System. out. println ("Enter 10 numbers" ); 11
12
Scanner sc = new Scanner (System. in); 13
14
for(i =0 ; i <10 ;++ i ) 15
arr [ i ]= sc . nextInt (); 16
17
for(i =0 ; i <10 ;++ i ) 18
sum =sum + arr [ i ]; 19
20
System. out. println ("Sum of numbers is:" + 21
} 22
23
} 24
for (i = 0 ; i < 10 ;++ i ) 1
{ 2
scanf ("%d" ,& arr [ i ]); 3
4
sum = sum + arr [ i ]
2
int main () 3
{ 4
int i , arr [ 10 ], sum = 0 ; 5
6
printf ("Enter 10 elements:" ); 7
for(i =0 ; i <10 ;++ i ) 8
scanf ("%d" ,& arr [ i ]); 9
10
for(i =0 ; i <10 ;++ i ) 11
sum = sum + arr [ i ]; 12
printf ("Sum of numbers is:%d" , sum ); 13
14
return 0 ; 15
} 16
#include <iostream> 1
2
using namespace std ; 3
4
int main () 5
{ 6
int i , arr [ 10 ], sum = 0 ; 7
8
cout << "Enter 10 elements:" ; 9
for(i =0 ; i <10 ;++ i ) 10
cin >> arr [ i ]; 11
12
for(i =0 ; i <10 ;++ i ) 13
sum = sum + arr [ i ]; 14
cout << "Sum of numbers is:" << sum ; 15
16
return 0 ; 17
} 18
import java . util. Scanner ; 1
2
3
public class Example12 { 4
5
public static void main (String [] args ) { 6
7
int i , sum = 0 ; 8
int arr []=new int [ 10 ]; 9
10
System. out. println ("Enter 10 numbers" ); 11
12
Scanner sc = new Scanner (System. in); 13
14
for(i =0 ; i <10 ;++ i ) 15
arr [ i ]= sc . nextInt (); 16
17
for(i =0 ; i <10 ;++ i ) 18
sum =sum + arr [ i ]; 19
20
System. out. println ("Sum of numbers is:" + 21
} 22
23
} 24
for (i = 0 ; i < 10 ;++ i ) 1
{ 2
scanf ("%d" ,& arr [ i ]); 3
4
sum = sum + arr [ i ]
Similar questions