Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please only give the answer in C. typedef stuct{ int array[20]; size_t size; }Se

ID: 3584500 • Letter: P

Question

Please only give the answer in C. typedef stuct{ int array[20]; size_t size; }Sets; Sets setUnion(Sets, Sets); int main (){ Sets 3}; Sets two = {{2,3}, 2}; Sets result = setUnion(one, two); if(result == NULL){ //use printf to give error message. }else{ //use printf to print the values in array in set 1. } } Sets setUnion(Sets one, Sets, two){ if(one.size + two.size > 20){ return NULL; }else{ return one; } } That's basically what I got in my program, problem is gcc wont' let me cast Sets to void*, so I can't have a function that returns either a Sets or a NULL. In main, i want to be able to determine whether the stuff returned from setUnion is NULL or a Sets, if its a Sets, then print the values in the array in the Sets result, otherwise print an error message. And yes, the instruction of the assignment said that setUnion takes two Sets struct, and returns 1 Sets back, and it should return a NULL of the sum of the two Sets's size is greater than 20.

Explanation / Answer

typedef stuct { int array[20]; size_t size; }Sets; Sets setUnion(Sets, Sets); int main () { int *k; k=NULL; Sets one = {{1,2,3}, 3}; Sets two = {{2,3}, 2}; Sets result = setUnion(one, two); if(result == k) { //use printf to give error message. } else { //use printf to print the values in array in set 1. } } Sets setUnion(Sets one, Sets, two) { if(one.size + two.size > 20) { return k; } else { return one; } }