#include <stdio.h>
#include <stdlib.h>
int main() {
int arr1[6]={-20,-2,3,0,10,20};
int arr2[4]={6,1,33,9};
int arr3[100];
int n1=5;
int n2=4;
int n3=n1+n2;
for(int i=0; i<n1; i++)
arr3[i]=arr1[i];
for(int i=0; i<n2; i++)
arr3[i + n1]= arr2[i];
printf("the marged array are: ");
for(int i=0; i<n3; i++)
printf("%d ",arr3[i]);
printf("\nFinal array after sorting: ");
for(int i = 0; i < n3; i++){
int temp;
for(int j = i+1; j < n3; j++) {
if(arr3[i] > arr3[j]) {
temp = arr3[i];
arr3[i] = arr3[j];
arr3[j] = temp;
}
}
}
for(int i = 0; i < n3 ; i++) //print sorted array
printf(" %d ",arr3[i]);
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter