WAP in C to Find all Roots of a Quadratic equation?

#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
float a, b, c;
float desc, r1, r2;
clrscr();
printf(“\nEnter the Values of a : “);
scanf(“%f”, &a);
printf(“\nEnter the Values of b : “);
scanf(“%f”, &b);
printf(“\nEnter the Values of c : “);
scanf(“%f”, &c);
desc = sqrt(b * b – 4 * a * c);
r1 = (-b + desc) / (2.0 * a);
r2 = (-b – desc) / (2.0 * a);
printf(“\nFirst Root : %f”, r1);
printf(“\nSecond Root : %f”, r2);
getch();
return(0);
}

Output :-

Quadratic

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s