-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab2_1.c
65 lines (64 loc) · 1.26 KB
/
lab2_1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<stdio.h>
int main()
{
int a,b,n=0,v=0;
printf("Enter the array sizes \n");
scanf("%d%d",&a,&b);
int a1[a],b1[b];
printf("Enter the contents of 1st array \n");
for(int i=0;i<a;i++)
{
scanf("%d",&a1[i]);
}
printf("Enter the contents of 2nd array \n");
for(int i=0;i<b;i++)
{
scanf("%d",&b1[i]);
}
printf("Elements after performing the union: \n ");
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
if(a1[i]==b1[j])
{
printf("%d ",a1[i]);
break;
}
}
}
printf("Elements after performing the intersection: \n ");
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
if(a1[i]==b1[j])
{
v++;
break;
}
}
if(v==0)
{
printf("%d ",a1[i]);
}
v=0;
}
for(int i=0;i<b;i++)
{
for(int j=0;j<a;j++)
{
if(b1[i]==a1[j])
{
v++;
break;
}
}
if(v==0)
{
printf("%d ",b1[i]);
}
v=0;
}
return 0;
}