Computer Science, asked by kowshiksh89, 9 days ago

Write a complete C program that finds real roots of a quadratic equation​

Answers

Answered by BrainIyKohinoor
0

Answer:

Design (Algorithm)

Start.

Read a, b, c values.

Compute d = b2 4ac.

if d > 0 then. r1 = b+ sqrt (d)/(2*a) r2 = b sqrt(d)/(2*a)

Otherwise if d = 0 then. compute r1 = -b/2a, r2=-b/2a. print r1,r2 values.

Otherwise if d < 0 then print roots are imaginary.

Stop.

Explanation:

Answered by Iwilltrytoanswer
0

Answer:

# include<stdio.h>

# include<conio.h>

# include<math.h>

main (){

float a,b,c,r1,r2,d;

printf (“enter the values of a b c”);

scanf (“ %f %f %f”, &a, &b, &c);

d= b*b – 4*a*c;

if (d>0){

r1 = -b+sqrt (d) / (2*a);

r2 = -b-sqrt (d) / (2*a);

printf (“The real roots = %f %f”, r1, r2);

}

else if (d= =0){

r1 = -b/(2*a);

r2 = -b/(2*a);

printf (“roots are equal =%f %f”, r1, r2);

}

else

printf(“Roots are imaginary”);

getch ();

}

Similar questions