I want to compare 2 arrays and if the element is common to both the arays then store it in the third aray and then print the common elements from 3rd array.But I am not understanding the correct way of its implementation.Here's what I have tried to do :

#include <stdio.h>

main()
{
int x,y,e;
int i,j;
int a[20];
int c[20];
int b[20];
printf("How many no of elements : ");
scanf("%d",&x);
printf("Enter the elements of set A");
for(i=0;i<x;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the elements of set B");
for(j=0;j<x;j++)
{
scanf("%d",&b[i]);
}

// How do I use the assignment operation ?

for(i=0;i<x-1;i++) {
for(j=i+1;j<x;j++)
if(a[j]==b[i])

c[y++]=a[j]; //Is this right?
}

//How Do I print the 3rd array ?

return 0;
}