// Intersection of Two Sets
#include<stdio.h>
#define SIZE 10
int main()
{
int a[SIZE],b[SIZE],i,j,m,n;
printf("Enter the Number of Elements in A : ");
scanf("%d",&m);
printf("Enter the Number of Elements in B : ");
scanf("%d",&n);
printf("\nSET-A\n");
for(i=0;i<m;i++)
{
printf("Enter the Elements a[%d] : ",i);
scanf("%d",&a[i]);
}
printf("\nSET- B\n");
for(j=0;j<n;j++)
{
printf("Enter the Elements b[%d] : ",j);
scanf("%d",&b[j]);
}
printf("\nA intersection B : {");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i]==b[j])
{
printf(" %d",a[i]);
break;
}
}
}
printf(" }\n");
return 0;
}
#include<stdio.h>
#define SIZE 10
int main()
{
int a[SIZE],b[SIZE],i,j,m,n;
printf("Enter the Number of Elements in A : ");
scanf("%d",&m);
printf("Enter the Number of Elements in B : ");
scanf("%d",&n);
printf("\nSET-A\n");
for(i=0;i<m;i++)
{
printf("Enter the Elements a[%d] : ",i);
scanf("%d",&a[i]);
}
printf("\nSET- B\n");
for(j=0;j<n;j++)
{
printf("Enter the Elements b[%d] : ",j);
scanf("%d",&b[j]);
}
printf("\nA intersection B : {");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i]==b[j])
{
printf(" %d",a[i]);
break;
}
}
}
printf(" }\n");
return 0;
}
Comments
Post a Comment