Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program will find the union and intersection of the two arrays (I wrote the first two functions, I really need help with the last two,

Program will find the union and intersection of the two arrays (I wrote the first two functions, I really need help with the last two, its 25% of my grade)

Write 2 more functions that will complete the program.

No subscripts are permitted in any function for this program including the inputData and displayData functions. You must use pointers to access dynamically allocated arrays and to control loop termination.

Code given by professor

#include #include // header file required for dynamic allocation of memory using namespace std;

void inputData(short *data, short size); // function to enter data into the array void displayData(short *data, short size); // function to display data in an array void get_union(short *set1, short size1, short *set2, short size2, short *union_array, short size_union); short *get_intersection(short *set1, short size1, short *set2, short size2, short *intersection, short size_intersection);

int main() { short *set1, size1, // first data set and size; do not put duplicate values in the data set *set2, size2, // second data set and size *union_array, size_union, // array to store the union of the two sets *intersection, size_intersection; // array to store the intersection of the two sets cout<<"Program will find the union and intersection of two sets of data "; cout<<"enter the number of values to store in the data set 1 or zero to terminate the program "; cin>>size1; while(size1) // loop to permit user to test many data sets { set1 = new(nothrow)short[size1]; // test pointer to verify memory was allocated if(!set1) { cout<<"Memory allocation error, program will terminate "; system("pause"); exit(0); } inputData(set1, size1); // print the contents of the array cout<<" there are "<

void inputData(short *data, short size) // function to enter data into the array

{

short count=1;

short *end=(data+size);

for( ;data

{

cout<<"Enter Number "<

cin>>*data;

cout<

}

}

void displayData(short *data, short size) // function to display data in an array

{

short count;

short *end=(data+size);

for(;data

{

cout<<"Number "<

}

}

void get_union(short *set1,short size1,short *set2,short size2,short *union_array,short size_union) // look at call statement to assist in completing this statement

{

}

short *get_intersection(short *set1, short size1, short *set2, short size2, short *intersection, short size_intersection) // look at call statement to assist in completing this statement

{

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

List the different categories of international employees. page 642

Answered: 1 week ago

Question

Explain the legal environments impact on labor relations. page 590

Answered: 1 week ago