0% found this document useful (0 votes)
52 views1 page

Quadratic

Uploaded by

Rahul Makwana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views1 page

Quadratic

Uploaded by

Rahul Makwana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

/* Quadratic Equation

Date:01/09/2025
Urvashiba Gohil
Rahul Makwana
*/

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

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

printf("enter the value of co-efficient a,b,c\n");


scanf("%f%f%f",&a,&b,&c);

discriminant=(b*b)-(4*a*c); // discriminant
printf("value of discriminant is=%f\n",discriminant);

if(discriminant<0) // case: discriminant < 0 (imaginary roots)


{
printf("both roots are imaginary\n");
}

if(discriminant==0) // case: discriminant = 0 (equal roots)


{
printf("both roots are same\n");
root1=root2=-b/(2*a);
printf("%f\n%f\n",root1,root2);
}
if(discriminant>0) // case: discriminant > 0 (real & distinct)
{
printf("both roots are real and distinct\n");
root1=(-b + sqrt(discriminant))/(2*a);
root2=(-b - sqrt(discriminant))/(2*a);
printf("%f\n%f\n",root1,root2);
}
}

OUTPUT:

enter the value of co-efficient a,b,c


1
5
3
value of discriminant is=13.000000
both roots are real and distinct
-0.697224
-4.302776

enter the value of co-efficient a,b,c


9
9
9
value of discriminant is=-243.000000
both roots are imaginary

enter the value of co-efficient a,b,c


1
4
4
value of discriminant is=0.000000
both roots are same
-2.000000
-2.000000

You might also like