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

2. (This is redoing of your previous homework problems. This time do this proble

ID: 3699354 • Letter: 2

Question

2. (This is redoing of your previous homework problems. This time do this problem by using user defined functions. Please create 3 script with 1) A User defined function that does not take any argument and does not return any value. 2) A User defined function that takes arguments but does not return any value. 3) A User defined function that takes arguments and returns a value (USE ARRAY FOR THE COEFFICIENTS!) Create a script that will solve a set of simultaneous equations ax + by-c dx + ey =f a, b, c, d, e, and fare user input ce-bf ae-bd af -cd ae-bd Your script should be able to calculate x and y. Also the script should ask the user whether he /she would like to continue on finding answers for other equations and then continue on with the answer "Y" Your output should have the format of -With given values of"a”, “b", “c","d", “e", and "f", the answer for x is ''Answer" and y is “Answer"

Explanation / Answer

1) In this part since function is not returning any value, will use void type. Pseudo code for finding X and Y

void calculate(){

char inputs[] = {'a', 'b', 'c', 'd', 'e', 'f'};

float x = (c*e - b*f)/(a*e - b*d);

float y = (a*f - c*d)/(a*e - b*d);

printf("With given values of a,b,c,d,e and f, the answer for x is %g and y is %g ", x,y);   

}

2. In this part we will ask user for values of a,b,c,d,e and f

void calculate(){

char inputs[10];

printf("Enter the values of a,b,c,d,e and f");

for(int i=0;i<6;i++){

printf("Enter number ");

//ask user for values of a, b, c, d, e and f

scanf("%d ", inputs[i]);

}

//store the user inputs in variables

int a = inputs[0];

  int b = inputs[1];

  int c = inputs[2];

   int d = inputs[3];

   int e = inputs[4];

  int f = inputs[5];

}

float x = (c*e - b*f)/(a*e - b*d);

float y = (a*f - c*d)/(a*e - b*d);

  printf("With given values of a,b,c,d,e and f, the answer for x is %g and y is %g ", x,y);

}

3) In this part since we have to return two values, we will return pointer to array which will have the values of x and y

float * calculate(){

char inputs[10];

printf("Enter the values of a,b,c,d,e and f");

for(int i=0;i<6;i++){

printf("Enter number ");

//ask user for values of a, b, c, d, e and f

scanf("%d ", inputs[i]);

}

//store the user inputs in variables

int a = inputs[0];

  int b = inputs[1];

  int c = inputs[2];

   int d = inputs[3];

   int e = inputs[4];

  int f = inputs[5];

}

float x = (c*e - b*f)/(a*e - b*d);

float y = (a*f - c*d)/(a*e - b*d);

float result[] = {x,y};

return result;

}