Advertisement
MAT4m

Untitled

Jan 13th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a[25],b[25],sum[50],i,j,k=1,n,m,s,temp;
  5. printf("Enter the number of element in first array :");
  6. scanf("%d",&n);
  7. printf("\nEnter the element of array :\n");
  8. for(i=1;i<=n;i++)
  9. scanf("%d",&a[i]);
  10. printf("\nEnter the number of element in second array :");
  11. scanf("%d",&m);
  12. printf("\nEnter the element of array :\n");
  13. for(i=1;i<=m;i++)
  14. scanf("%d",&b[i]);
  15. s=m+n;
  16. for(i=1;i<=s;i++)
  17. {
  18. if(i<=n)
  19. {
  20. sum[i]=a[i];
  21. }
  22. else
  23. {
  24. sum[i]=b[k];
  25. k=k+1;
  26. }
  27. }
  28. for(i=1;i<=s;i++)
  29. {
  30. for(j=1;j<=s;j++)
  31. {
  32. if(sum[i]>=sum[j])
  33. {
  34. temp=sum[i];
  35. sum[i]=sum[j];
  36. sum[j]=temp;
  37. }
  38. }
  39. }
  40. printf("\nElement of array after merging and sorting :\n");
  41. for(i=1;i<=s;i++)
  42. printf("%d\t",sum[i]);
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement