Program to read the values for coefficients a,b and c of a quadratic equation ax²+bx+c=0.

Problem Analysis:

The problem is to read the values of coefficient a,b,c of quadratic equation ax²+bx+c=0 and to find the equation of the roots.

i.e. r1 =(-b + sqrt (d) /(2*a);                                            d=(b*b)-(4*a*c);

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


Input variables          Processing variables      Output variables          Necessary header files


a(int)                             r1=(-b+sqrt(d)/(2*a);      r1(float)                         stdio.h

b(int)                             r2=(-b-sqrt(d)/(2*a);       r2(float)                         conio.h

c(int)                             d=(b*b) – (4*a*c);                                                 math.h

d(int)

r1(float)

r2(float)


 

Algorithms:

1.start

2.Define : a,b,c.d,r1(float),r2(float).

3.Input : a,b,c from the user.

4. Calculate:

d=(b*b) -(4*a*c)

if (a>c),r1=(-b+sqrt(d)/(2*a);

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

5.print the result as r1/r2 else the root is imaginary if d<0.

6.End.

 

Codes:

Outputs:

Compiling  , Debugging and  Testings

Enter  a   b  c:  100  300  200

answer=-1   answer  =-2

About Programmingfaster

We the teams of programming faster managed to provide an effective information about the codes of different programming languages.Hope you will learn and understand the codes fast and easy. It's absolutely free, expanding and precise. Our main target is to help those new starters and aid them as far as possible to pave their future in the area of programming. Hoping support and recommendations!
This entry was posted in C, precise examples and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *