SlideShare a Scribd company logo
AIM : TO PERFORM SET OPERATIONS-UNION,INTERSECTION AND
DIFFRENCE,ETC.
*/
#include<stdio.h>
void main()
{
int a[15],b[15],c[15],m,n,i,j,k,x,flag;
printf("n enter the size of set A");
scanf("%d",&m);
printf("n enter the size of set B");
scanf("%d",&n);
printf("n enter the elements of set A");
for(i=0;i<m;i++)
{
scanf("%d",&a[i]);
}
printf("n enter the elments of set B");
for(j=0;j<n;j++)
{
scanf("%d",&b[j]);
}
k=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i]==b[j])
{
c[k]=a[i];
k++;
}
}
}
printf(" intersection of set A & B is n");
for(i=0;i<k;i++)
{
printf("%dt",c[i]);
}
k=0,x=0;
for(i=0;i<m;i++)
{
c[x]=a[i];
x++;
}
k=x;
for(i=0;i<m;i++)
{
flag=0;
for(j=0;j<n;j++)
{
if(a[j]==b[i])
{
flag=0;
break;
}
else
flag=1;
}
if(flag==1)
{
c[k]=b[i];
k++;
}
}
printf("n");
printf(" union of sets A & B is n");
for(i=0;i<k;i++)
{
printf("%dt",c[i]);
}
k=0;
for(i=0;i<m;i++)
{
flag=0;
for(j=0;j<n;j++)
{
if(a[i]==b[j])
{
flag=0;
break;
}
else
flag=1;
}
if(flag==1)
{
c[k]=a[i];
k++;
}
}
printf("n");
printf("differnce A-B is n");
for(i=0;i<k;i++)
{
printf("%dt",c[i]);
}
k=0;
for(i=0;i<m;i++)
{
flag=0;
for(j=0;j<n;j++)
{
if(b[i]==a[j])
{
flag=0;
break;
}
else
flag=1;
}
if(flag==1)
{
c[k]=b[i];
k++;
}
}
printf("n");
printf("differnce B-A is n");
for(i=0;i<k;i++)
{
printf("%dt",c[i]);
}
}
/**********************************************************
OUTPUT :-
enter the size of set A
5
enter the size of set B
5
enter the elements of set A
1 8 5 3 6
enter the elments of set B
9 5 8 2 4
intersection of set A & B is
8 5
union of sets A & B is
1 8 5 3 6 9 2 4
differnce A-B is
1 3 6
differnce B-A is
9 2 4

More Related Content

What's hot

Scanfill polygon
Scanfill polygonScanfill polygon
Scanfill polygon
Sonia Pahuja
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
Pruebabfs
PruebabfsPruebabfs
PruebabfsJorge
 
Heep implementation in c
Heep implementation in cHeep implementation in c
Heep implementation in c
HapPy SumOn
 
Alocação Dinâmica em C
Alocação Dinâmica em CAlocação Dinâmica em C
Alocação Dinâmica em C
Luiz Francisco Bozo
 
PROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quintoPROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
Jordan Puente
 
Dado un vector imprimir cuantas vocales tiene
Dado un vector imprimir cuantas vocales tieneDado un vector imprimir cuantas vocales tiene
Dado un vector imprimir cuantas vocales tiene
Popular University of Cesar
 
Doi xung mang mot chieu
Doi xung mang mot chieuDoi xung mang mot chieu
Doi xung mang mot chieu
Nguyen Van Hung
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble, Meita Jayani
 
Bubble sort
Bubble sortBubble sort
Bubble sort
Hitesh Kumar
 
N primo clase programa
N primo clase programaN primo clase programa
N primo clase programa
Leydyca Leydyca
 
NSEG17 バグのはなし
NSEG17 バグのはなしNSEG17 バグのはなし
NSEG17 バグのはなし
Daichi OBINATA
 
Bai lam chuong 3
Bai lam chuong 3Bai lam chuong 3
Bai lam chuong 3tran thai
 
Fcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt ChartFcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt Chart
One97 Communications Limited
 
C - Pattern - Code - [Future Programming]
C - Pattern - Code - [Future Programming]C - Pattern - Code - [Future Programming]
C - Pattern - Code - [Future Programming]
Future Programming
 
Quick sort
Quick sortQuick sort
Quick sort
Hitesh Kumar
 
listing output program C
listing output program Clisting output program C
listing output program C
AdjievanGestu
 

What's hot (20)

Scanfill polygon
Scanfill polygonScanfill polygon
Scanfill polygon
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Pruebabfs
PruebabfsPruebabfs
Pruebabfs
 
Heep implementation in c
Heep implementation in cHeep implementation in c
Heep implementation in c
 
Alocação Dinâmica em C
Alocação Dinâmica em CAlocação Dinâmica em C
Alocação Dinâmica em C
 
PROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quintoPROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
PROBLEMAS DE PROGRAMACION 2 por jordan puente quinto
 
Dado un vector imprimir cuantas vocales tiene
Dado un vector imprimir cuantas vocales tieneDado un vector imprimir cuantas vocales tiene
Dado un vector imprimir cuantas vocales tiene
 
Doi xung mang mot chieu
Doi xung mang mot chieuDoi xung mang mot chieu
Doi xung mang mot chieu
 
Cpro
CproCpro
Cpro
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
N primo clase programa
N primo clase programaN primo clase programa
N primo clase programa
 
NSEG17 バグのはなし
NSEG17 バグのはなしNSEG17 バグのはなし
NSEG17 バグのはなし
 
Bai lam chuong 3
Bai lam chuong 3Bai lam chuong 3
Bai lam chuong 3
 
Programas for
Programas forProgramas for
Programas for
 
Fcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt ChartFcfs Cpu Scheduling With Gantt Chart
Fcfs Cpu Scheduling With Gantt Chart
 
C - Pattern - Code - [Future Programming]
C - Pattern - Code - [Future Programming]C - Pattern - Code - [Future Programming]
C - Pattern - Code - [Future Programming]
 
Quick sort
Quick sortQuick sort
Quick sort
 
listing output program C
listing output program Clisting output program C
listing output program C
 
Numeros primos
Numeros primosNumeros primos
Numeros primos
 

Union