Search:

Submit Article

# Program to calculate roots of 3 numbers using root1 = (-b + sqrt(discriminant))/(2.0*a) and root2 = (-b - sqrt(discriminant))/(2.0*a) formula

Posted By: Phil Sanchez     Category: C Programming     Views: 3703

## Code for Program to calculate roots of 3 numbers using root1 = (-b + sqrt(discriminant))/(2.0*a) and root2 = (-b - sqrt(discriminant))/(2.0*a) formula in C Programming

```#include<math.h>

void main()
{
float a,b,c,discriminant,root1,root2;
clrscr();

printf("Input values of a,b and c \n");
scanf("%f %f %f",&a,&b,&c);

discriminant = (b*b) - (4*a*c);

if(discriminant < 0)
{
printf("\n\nROOTS ARE IMAGINARY\n");
}
else
{
root1 = (-b + sqrt(discriminant))/(2.0*a);
root2 = (-b - sqrt(discriminant))/(2.0*a);
printf("\n\nRoot1 = %5.2f\n\nRoot2 = %5.2f\n",root1,root2);
}
getch();
}
```
Share:

 Phil Sanchez author of Program to calculate roots of 3 numbers using root1 = (-b + sqrt(discriminant))/(2.0*a) and root2 = (-b - sqrt(discriminant))/(2.0*a) formula is from New York, United States. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!