Answer:
In C
#include <stdio.h>
#include<math.h>
void myfunc(double *a, double *b, double *c) {
double x1, x2;
x1 = (-(*b) + sqrt((*b)*(*b)- 4*(*a)*(*c)))/(2*(*a));
x2 = (-(*b) - sqrt((*b)*(*b) - 4*(*a)*(*c)))/(2*(*a));
printf("x1 = %f\\",x1);
printf("x2 = %f\\",x2);}
int main () {
double a,b,c;
printf("a: "); scanf("%lf", &a);
printf("b: "); scanf("%lf", &b);
printf("c: "); scanf("%lf", &c);
myfunc(&a, &b, &c);
return 0;}
Step-by-step explanation:
#include <stdio.h>
#include<math.h> --- This represents step 1
Step 2 begins here
This gets the values of a, b and c from main by reference
void myfunc(double *a, double *b, double *c) {
This declares x1 and x2
double x1, x2;
Calculate x1
x1 = (-(*b) + sqrt((*b)*(*b)- 4*(*a)*(*c)))/(2*(*a));
Calculate x2
x2 = (-(*b) - sqrt((*b)*(*b) - 4*(*a)*(*c)))/(2*(*a));
Print x1
printf("x1 = %f\\",x1);
Print x2
printf("x2 = %f\\",x2);}
Step 3 begins here
int main () {
Declare a, b and c as double
double a,b,c;
Get input for a, b and c
printf("a: "); scanf("%lf", &a);
printf("b: "); scanf("%lf", &b);
printf("c: "); scanf("%lf", &c);
Call the function to calculate and print x1 and x2
myfunc(&a, &b, &c);
return 0;}