Question: Modify set_operations.c the following program so that it includes the following functions: void set_difference(int *a, int *b, int n, int *difference); void set_complement(int *a, int

Modify set_operations.c the following program so that it includes the following functions:

void set_difference(int *a, int *b, int n, int *difference);

void set_complement(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 VARIABLES AND ALL USE OF THE [] OPERATOR IN THE FUNCTION.

MODIFY THIS PROGRAM BELOW:

#include

int main()

{

//Declaring Variables

int a[10]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

int b[10]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

int n1,n2;

int i=0;

int x;

printf("Please enter the number of elements in set A: ");

scanf("%d",&n1);

printf("Enter the numbers in set A: ");

for(i=0;i

{

scanf("%d",&x);

a[x]=1;

}

printf("Please enter the number of elements in set B: ");

scanf("%d",&n2);

printf("Enter the numbers in set B: ");

for(i=0;i

{

scanf("%d",&x);

b[x]=1;

}

//Calculates the difference of A and B

printf("The difference of set A and B is: ");

for(i=0;i<10;i++)

{

if(a[i]==1&&b[i]==0)

printf("%d ",i);

}

printf(" ");

printf("The complement of set A is: ");

for( i=0;i<10;i++)

{

if(a[i]==0)

printf("%d ",i);

}

printf(" ");

printf("The complement of set B is: ");

for(i=0;i<10;i++)

{

if(b[i]==0)

printf("%d ",i);

}

printf(" ");

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!