I am in the process of writing a program that contains sets A and B and a universal set U. The code must first check that A and B are part of the universal set. Then I must find the Union, Intersection, difference, complement (of only A), symmetric difference, and the Cartesian product of sets A and B.Below is my code that I have done so far. I am getting an error that says "expected declaration or statement at end of input" on my last line. Can you tell me what is wrong? My code for the difference is also not working or printing.
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int k,s,n, i=0,j,size=20;
int U[20], A[20],B[20], C[20];
printf ("Enter the elements (Integer Between -100 and 100) for the universal set :");
for (i=0;i<20;i++)
{
scanf ("%d",&U[i]);
}
printf ("Enter the elements (Integer Between -100 and 100) for set A :");
for (i=0;i<20;i++)
{
scanf ("%d",&A[i]);
}
printf ("Enter the elements (Integer Between -100 and 100) for the set B :");
for (i=0;i<20;i++)
{
scanf ("%d",&B[i]);
}
printf ("Elements of the universal set you entered:\n");
for (i=0;i<20;i++)
{
printf("\t%d",U[i]);
}
printf ("\n");
printf ("Elements of set A you entered:\n");
for (i=0;i<20;i++)
{
printf("\t%d",A[i]);
}
printf ("\n");
printf ("Elements of set B you entered:\n");
for (i=0;i<20;i++)
{
printf("\t%d",B[i]);
}
printf ("\n");
printf("\nThe intersection of the two arrays are: ");
printf ("\n The Difference of A and B are: ");
for (i = 0; i < n; ++i)
{
C[i] = A[i] & ~B[i];
}
printf ("\t%d",C[i]);
printf("\n\n\nThe union of the two arrays are: ");
while (i<size)
{
k=0;
for (j=0; j<size; j++)
{
if (A[i] == B[j])
{
printf("\t%d", A[i]);
i++;k++;
}
}
if(k==0)
i++;
}
i=0;
while (i<size)
{
k=0;
for (j=0; j<size; j++)
{
if (B[i] == A[j])
{
i++;k++;
}
}
if(k==0)
{
printf("\t%d",B[i]);
i++;
}