# Find Union and Intersection of Two Sets C Program

## C Program To Find Union and Intersection of Two Sets

Learn how to perform Set Operations using Functions in C Programming Language. This C program to find union and intersection of Two Arrays with Functions takes two different arrays as input from the user for Set A and Set B. The intersection elements and union elements elements are stored in different arrays.

#### What is a Set?

A set is a collection of distinct objects or elements. It is therefore, a well defined collection of distinct elements. The union of set A and B is represented by A ∪ B, and it will form a resultant set which consists of all the elements of sets A and B without any repetition. The intersection of set A and B is represented by A ∩ B, and it forms a resultant set that consists of the common elements from the sets A and B.

This code for calculation intersection and union requires the arrays containing set elements to be in sorted order. If they are not in sorted order, then there will be a problem in fetching the union of the two sets.

#### Example of Union and Intersection of Two Arrays

A = {1, 2, 3, 4, 5, 6}

B = {4, 5, 6, 7, 8, 9}

Union: (A ∪ B) = {1, 2, 3, 4, 5, 6, 7, 8, 9}

Intersection: (A ∩ B) = {4, 5, 6}

Must Read: C Program To Find Value of Arithmetic Expression

#### Output

If you get any compilation errors or have any doubts in this C program to find union and intersection of two Sets, let us know about it in the comment section below.

#### Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

### 2 thoughts on “Find Union and Intersection of Two Sets C Program”

• October 17, 2016 at 9:31 am