Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int l1,l2;
- int a[100],b[100],c[200];
- int i,j,temp;
- printf("Enter the limit of the two arrays.\n");
- scanf("%d%d",&l1,&l2);
- printf("Now enter the first array.\n");
- for(i=0; i<l1; i++)
- scanf("%d",&a[i]);
- for (i = 0 ; i < ( l1 - 1 ); i++)
- {
- for (j = 0 ; j < l1 - i - 1; j++)
- {
- if (a[j] > a[j+1])
- {
- temp = a[j];
- a[j] = a[j+1];
- a[j+1] = temp;
- }
- }
- }
- printf("Now enter the second array.\n");
- for(i=0; i<l2; i++)
- scanf("%d",&b[i]);
- for (i = 0 ; i < ( l2 - 1 ); i++)
- {
- for (j = 0 ; j < l2 - i - 1; j++)
- {
- if (b[j] > b[j+1])
- {
- temp = b[j];
- b[j] = b[j+1];
- b[j+1] = temp;
- }
- }
- }
- printf("The third array is:-");
- for(i=0; i<l1; i++)
- c[i] = a[i];
- for(i=l1; i<l1+l2; i++)
- c[i] = b[i-l1];
- for (i = 0 ; i < (l1 + l2 - 1 ); i++)
- {
- for (j = 0 ; j < l1 + l2 - i - 1; j++)
- {
- if (c[j] > c[j+1])
- {
- temp = c[j];
- c[j] = c[j+1];
- c[j+1] = temp;
- }
- }
- }
- for(i=0; i<l1+l2; i++)
- printf("%d ",c[i]);
- }
- //Output:-
- //Enter the limit of the two arrays.
- //5
- //5
- //Now enter the first array.
- //1
- //2
- //3
- //4
- //5
- //Now enter the second array.
- //5
- //4
- //3
- //2
- //1
- //The third array is:-1 1 2 2 3 3 4 4 5 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement