Labwork 1
Labwork 1
Labwork 1
Solution
For union and intersection
#include<stdio.h>
int main()
{
int a[100],b[100];
int n1,i,j,n2,c,s;
printf("Enter first array elements number\n\t");
scanf("%d",&n1);
printf("Enter %d elemets of first array\n",n1);
for(i=0;i<n1;i++)
scanf("%d",&a[i]);
printf("Enter second array elements number\n\t");
scanf("%d",&n2);
printf("Enter %d elemets of second array\n",n1);
for(i=0;i<n2;i++)
scanf("%d",&b[i]);
for(i=0;i<s;i++)
printf("%d",a[i]);
}
For difference
#include<stdio.h>
int i;
if (u==0) return 0;
return (0);
int main()
int i,j,k;
scanf("%d",&m);
for(i=0;i<m;i++ )
scanf("%d",&p[i]);
scanf("%d",&n);
for(i=0;i<n;i++ ) scanf("%d",&q[i]);
k=0;
for (i=0;i<m;i++)
for (j=0;j<n;j++)
if (p[i]==q[j])
{ break;
if(j==n)
if(!ifexists(r,k,p[i]))
r[k]=p[i];
k++;
}
printf("\nThe difference of the two array is:\n");
for(i = 0;i<k;i++)
printf("%d\n",r[i]);