answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

void Union(int set1[10],int set2[10],int m,int n);

void Intersection(int set1[10],int set2[10],int m,int n);

void main()

{

{

int a[10],b[10],m,n,i,j;

int ch;

clrscr();

printf("\nEnter the no of elements in first set:");

scanf("%d",&m);

printf("\nEnter the elements:");

for(i=0;i<m;i++)

{

scanf("%d",&a[i]);

}

printf("\nElement of First set:\n");

for(i=0;i<m;i++)

{

printf("\t%d",a[i]);

}

printf("\nEnter the no of elements in second set:");

scanf("%d",&n);

printf("\nEnter the elements:");

for(i=0;i<n;i++)

{

scanf("%d",&b[i]);

}

printf("\nElement of second set\n");

for(i=0;i<n;i++)

{

printf("\t%d",b[i]);

}

while(1)

{

printf("\n\tMenu\n\n1.Union\n2.Intersection");

printf("\n3.exit");

printf("\nenter your choice:-");

scanf("%d",&ch);

switch(ch)

case 1:

union(a,b,m,n);

break;

case 2:

intersection(a,b,m,n);

break;

case 3:

exit(0);

}

getch();

}

}

void union(int a[10],int b[10],int m,int n)

{

int c[20],i,j,k=0,flag=0;

for(i=0;i<m;i++)

{

c[k]=a[i];

k++;

}

for(i=0;i<n;i++)

{

flag=0;

for(j=0;j<m;j++)

{

if(b[i]==c[j])

{

flag=1;

break;

}

}

if(flag==0)

{

c[k]=b[i];

k++;

}

}

printf("\nElement of resultant set\n");

for(i=0;i<k;i++)

{

printf("\t%d",c[i]);

}

}

void intersection(int a[10],int b[10],int m,int n)

{

int c[20],i,j,k=0,flag=0;

for(i=0;i<m;i++)

{

flag=0;

for(j=0;j<n;j++)

{

if(a[i]==b[j])

{

flag=1;

break;

}

}

if(flag==1)

{

c[k]=a[i];

k++;

}

}

printf("\nElement of resultant set\n");

for(i=0;i<k;i++)

{

printf("\t%d",c[i]);

}

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

Write a program to find intersection between two arrays?

#include&lt;stdio.h&gt;


How do you write c programme to find proper subset of a given string?

you can use strstr()


How can you find the center of a regular polygon?

You can find the intersection of the angle bisectors or the intersection of the perpendicular bisectors of each side.


How do you find the point of intersection of a parallelogram?

It would help to know "... the point of intersection of a parallelogram" and what!


Write a c program to generate student mark details using union and find total and average and grade?

write a c program to display marks,total,average,grade using union


Write a programme to find greater among two numbers in c plus plus?

You could use an if, but the ternary operator is especially compact for this purpose: result = a &gt; b ? a : b;


Why use max for union and min for intersection?

The reason we use max for union is because the union of two sets should include all elements from both sets, so the max operation ensures that the larger of the two elements is included. Conversely, we use min for intersection because we want to find the common elements shared by both sets, so the min operation ensures we only include elements that are in both sets.


What do you find at the intersection of a plane and a line?

another point


Where can you find a programme that you can make graffitti writing?

www.graffiticreator.net/


I thought I un-installed a program that the computer insists is still there and how do I find it?

if you think that you have uninstall a programme but it is still there in your computer you need check in the programme files where you will see the list of programme .....


What do you find at the intersection of a plane an a line?

Unless the line is a subset of the plane, the intersection is a point.


How do you find the center of a circle?

it is the intersection of the medians of two cords!