Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Follow all the instructions given below (especially the instructions in bold): Write a C program that reads in two sets of numbers A and B,
Follow all the instructions given below (especially the instructions in bold):
Write a C program that reads in two sets of numbers A and B, and calculates and print their difference of set A and B: A - B, complement of set A: Aand complement of set B: B . A -B is the set of elements that appear in A but not in B, and that is the set of every element that is not in A. The values in the sets are restricted to the range 0... 9 and should include the following functions within the program: void set difference(int *a, int *b, int n, int *difference); void setacomplement(int *a, int n, int *complement); set difference function:it should find the difference of the set represented by array a and set represented by array b and store the result in the set represented by array difference set complement function: it should find the complement of the set represented by array a store the result in the set represented by array complement. Both functions should use pointer arithmetic - not subscripting - to visit array elements. In other words, eliminate the loop index varables and all use of the operator in the function Do not declare an integer variable within your function and use that integer variable to iterate through the loop instead declare a pointer and use that pointer to iterate through the loop in the function: inti; Do not use the above code or anything similar in your functions but instead use a pointer to loop through the for loop! The program will read in the number of element in the first set, for example, 4, then read in the numbers in the set, for example, 3 6 8 9. The repeat for the second set. The two sets do not necessarily are of the same size The sets are stored using arrays of Os and 1s. Calculate the difference of A and B, and complements of the two sets and display the result. Sample input/output Please enter the number of elements in set A: 3 Enter the numbers in set A: 3 5 8 Please enter the number of elements in set B: 4 Enter the numbers in set B: 7 59 3 Output The difference of set A and B is: 8 The complement of set A is: 0 124679 The complement of set B is: 0 1 246 8
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started