-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintersection.c
More file actions
29 lines (29 loc) · 779 Bytes
/
Copy pathintersection.c
File metadata and controls
29 lines (29 loc) · 779 Bytes
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
#include <stdio.h>
int main()
{
int a[100],b[100],c[100],n,m,co=0,i,j,k;
printf("Enter number of elements of first array\n");
scanf("%d",&n);
printf("Enter the number of elements in second array\n");
scanf("%d",&m);
printf("Enter the elments of the first array\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the element of the second array\n");
for(i=0;i<m;i++){
scanf("%d",&b[i]);
k=0;
for(j=0;j<n;j++){
if(a[j]==b[i]){
k++;
break; }
}
if(k==1){
c[i]=b[i];
co++;}
}
printf("Array after intersection is\n");
for(i=0;i<co;i++)
printf("%d\n",c[i]);
return 0;
}