0% found this document useful (0 votes)
8 views

sum of array using function

The document contains a C program that merges two user-defined arrays and sorts the combined array. It prompts the user for the sizes and elements of both arrays, combines them into a new array, and then sorts this array using a nested loop. Finally, it prints the sorted array to the console.

Uploaded by

abhiram.ch.2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

sum of array using function

The document contains a C program that merges two user-defined arrays and sorts the combined array. It prompts the user for the sizes and elements of both arrays, combines them into a new array, and then sorts this array using a nested loop. Finally, it prints the sorted array to the console.

Uploaded by

abhiram.ch.2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>

int main(){
int n,m;
printf("enter the size of first array");
scanf("%d",&n);
printf("enter the size of second array");
scanf("%d",&m);
int a[n];
int b[m];
int d=m+n;
int c[d];
for(int i = 0;i<n;i++){
printf("enter the elements for first array");
scanf("%d",&a[i]);
}
for(int i = 0;i<m;i++){
printf("enter the elements for second array");
scanf("%d",&b[i]);
}
for(int i = 0;i<n;i++){
c[i]=a[i];
}

for(int i = 0;i<d;i++){
c[i+n]=b[i];

for(int i = 0;i<d;i++){
printf("%d",c[i]);
}

for(int i = 0;i<d;i++){
for(int j = 0;j<d;j++){
if(i == j){
continue;
}
else if(c[j]>c[i]){
int temp = c[i];
c[i] = c[j];
c[j] = temp;
}
}
}

for(int i = 0;i<d;i++){
printf("%d",c[i]);
}

You might also like