#include<stdio.h>
main()
{
int a[100],b[100],u[200],n1,n2,i,j,k,f;
printf("\nEnter number of terms of the first set=");
scanf("%d",&n1);
printf("\nEnter the elements of the first set=");
for(i=0;i<n1;i++)
{
scanf("%d",&a[i]);
}
printf("\nEnter number of terms of the second set=");
scanf("%d",&n2);
printf("\nEnter the elements of the second set=");
for(i=0;i<n2;i++)
{
scanf("%d",&b[i]);
}
printf("\nThe elements of the first set=");
for(i=0;i<n1;i++)
{
printf("%d ",a[i]);
}
printf("\nThe elements of the second set=");
for(i=0;i<n2;i++)
{
printf("%d ",b[i]);
}
j=0;
for(i=0;i<n1;i++)
{
f=0;
for(k=0;k<n2;k++)
{
if(a[i]==b[k])
{
u[j++]=b[k];
}
}
}
printf("\nThe intersaction=");
if(j==0)
printf("NULL");
else
{
for(i=0;i<j;i++)
{
printf("%d ",u[i]);
}
}
}
main()
{
int a[100],b[100],u[200],n1,n2,i,j,k,f;
printf("\nEnter number of terms of the first set=");
scanf("%d",&n1);
printf("\nEnter the elements of the first set=");
for(i=0;i<n1;i++)
{
scanf("%d",&a[i]);
}
printf("\nEnter number of terms of the second set=");
scanf("%d",&n2);
printf("\nEnter the elements of the second set=");
for(i=0;i<n2;i++)
{
scanf("%d",&b[i]);
}
printf("\nThe elements of the first set=");
for(i=0;i<n1;i++)
{
printf("%d ",a[i]);
}
printf("\nThe elements of the second set=");
for(i=0;i<n2;i++)
{
printf("%d ",b[i]);
}
j=0;
for(i=0;i<n1;i++)
{
f=0;
for(k=0;k<n2;k++)
{
if(a[i]==b[k])
{
u[j++]=b[k];
}
}
}
printf("\nThe intersaction=");
if(j==0)
printf("NULL");
else
{
for(i=0;i<j;i++)
{
printf("%d ",u[i]);
}
}
}
No comments:
Post a Comment