Code:
#include <stdio.h>
#define SIZE 10
#define SIZE1 12
int main(void)
{
int i;
int j;
int A[SIZE];
int B[SIZE1];
int intersection[SIZE];
int counter = 0;
int found;
int k;
for (i = 0; i < SIZE; i++)
{
printf("Enter number: ");
scanf("%d", &A[i]);
}
for(i = 0; i < SIZE; i++)
{
printf("%d\n", A[i]);
}
for (i = 0; i < SIZE1; i++)
{
printf("Enter number: ");
scanf("%d", &B[i]);
}
for(i = 0; i < SIZE1; i++)
{
printf("%d\n", B[i]);
}
for(i = 0; i < SIZE; i++)
{
for(j = 0; j < SIZE1; j++)
{
if (A[i] == B[j])
{
intersection[counter] = A[i];
counter++;
}
}
}
found = 0;
for (k = 0; k < SIZE; k++) /* for every element of intersection[] */
{
if (A[i] == intersection[k])
found = 1; /* A[i] is already in the intersection array */
}
if (found == 0) /* if not already in intersection */
{
found=intersection+A[i];
counter++;
}
if (counter > 1)
{
printf("The intersection is: ");
for(j = 0; j < counter; j++)
printf("%d ", intersection[j]);
printf("\n");
}
else
printf("There is no intersection\n");
return 0;
}
Still does the same, must have messed up your code somewhere.