Problem Solving: Union and Intersection of Sets (Using Functions)

Learn to create a program that finds the union and intersection of two sets using functions.

void loadSet(const char Msg[], int S[ ], int &size, ifstream &rdr);
void sort(int S[ ], int size);
void setPrint(const char Msg[ ], int S[ ], int size);
bool isPresent(int S[ ], int size, int t);
Assume you have the implementation of the above 4 functions.
void UNION(int A[ ], int sizeA, int B[ ], int sizeB, int UnionSet[ ], int &sizeU)
// Write your code here
void intersection(int A[ ], int sizeA,int B[ ], int sizeB,int IntersectionSet[ ],int& iSize)
// Write your code here
int main()
const int capacity = 500;
int A[capacity] = { 0 }, B[capacity] = { 0 }, sizeA, sizeB;
ifstream rdr("Sets.txt");
loadSet("A",A, sizeA, rdr);
loadSet("B",B, sizeB, rdr);
//Sorting the two sets
//Sorting A and B
sort(A, sizeA);
sort(B, sizeB);
// Displaying the two sets
setPrint("A", A, sizeA);
setPrint("B", B, sizeB);
// Write your code here.
// UNION(....);
// intersection(....);
return 0;

Get hands-on with 1200+ tech skills courses.