Answer the question
In order to leave comments, you need to log in
How to find the sum of the elements of an array in C?
#include <stdio.h>
int main()
{
int i, n,m,d, a[200], b[200], f=1,k,j,tmp,sum;
printf("Intput n:");
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
printf("Intput m:");
scanf("%d", &m);
for (i = 0; i < m; i++)
scanf("%d", &b[i]);
k=m;
for (i = 0; i < n; i++)
{
for (d = 0; d < m; d++)
{
if (b[d] == a[i])
f = 0;
}
if (f)
{
b[k++] = a[i];
}
f = 1;
}
for(i = 0 ; i < k - 1; i++)
{
for(j = 0 ; j < k - i - 1 ; j++)
{
if(b[j] > b[j+1])
{
tmp = b[j];
b[j] = b[j+1] ;
b[j+1] = tmp;
}
}
}
for (i = 0; i < k; i++)
printf("%d ", b[i]);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question