Programming in algorithm analysis Implement a program that f

Programming in algorithm analysis

•Implement a program that finds the zero of a function
f(n) = 8n2 – 64n lg n

Solution


#include <stdio.h>

#include <math.h>

int main()

{

double a, b, c, dete, root_1,root_2, rp, ip;

printf(\"Enter coefficients a, b and c: \");

scanf(\"%lf %lf %lf\",&a, &b, &c);

dete = b*b-4*a*c;

// condition for real and different roots

if (dete > 0)

{

// sqrt() function returns square root

root_1 = (-b+sqrt(dete))/(2*a);

root_2 = (-b-sqrt(dete))/(2*a);

printf(\"root_1 = %.2lf and root_2 = %.2lf\",root_1 , root_2);

}

//condition for real and equal roots

else if (dete == 0)

{

root_1 = root_2 = -b/(2*a);

printf(\"root_1 = root_2 = %.2lf;\", root_1);

}

// if roots are not real

else

{

rp = -b/(2*a);

ip = sqrt(-dete)/(2*a);

printf(\"root_1 = %.2lf+%.2lfi and root_2 = %.2f-%.2fi\", rp, ip, rp, ip);

}

return 0;

}

#include <stdio.h>

#include <math.h>

int main()

{

double a, b, c, dete, root_1,root_2, rp, ip;

printf(\"Enter coefficients a, b and c: \");

scanf(\"%lf %lf %lf\",&a, &b, &c);

dete = b*b-4*a*c;

// condition for real and different roots

if (dete > 0)

{

// sqrt() function returns square root

root_1 = (-b+sqrt(dete))/(2*a);

root_2 = (-b-sqrt(dete))/(2*a);

printf(\"root_1 = %.2lf and root_2 = %.2lf\",root_1 , root_2);

}

//condition for real and equal roots

else if (dete == 0)

{

root_1 = root_2 = -b/(2*a);

printf(\"root_1 = root_2 = %.2lf;\", root_1);

}

// if roots are not real

else

{

rp = -b/(2*a);

ip = sqrt(-dete)/(2*a);

printf(\"root_1 = %.2lf+%.2lfi and root_2 = %.2f-%.2fi\", rp, ip, rp, ip);

}

return 0;

}

Programming in algorithm analysis •Implement a program that finds the zero of a function f(n) = 8n2 – 64n lg nSolution #include <stdio.h> #include <mat
Programming in algorithm analysis •Implement a program that finds the zero of a function f(n) = 8n2 – 64n lg nSolution #include <stdio.h> #include <mat
Programming in algorithm analysis •Implement a program that finds the zero of a function f(n) = 8n2 – 64n lg nSolution #include <stdio.h> #include <mat

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site