C Saved Program: gifted-rain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include <stdio.h>

int main(int argc,char *argv[]  ){

double a,b,c,d,root_1,root_2;

printf("the values of a, b, c respectively is =  ");
scanf(" %lf %lf %lf ", &a,&b,&c);

d=sqrt((b*b)-(4*a*c));
root_1=((-b)+(sqrt(d)))/2*a;
root_2=((-b)-(sqrt(d)))/2*a;

if (d==0){
root_1=((-b)+(sqrt(d)))/2*a;
    printf("there is only one root i.e = %f",root_1);
}
else if(d<0)
{
    printf("there are no real roots")
}
else if (d>0) 
{
    root_1=((-b)+(sqrt(d)))/2*a;
    root_2=((-b)-(sqrt(d)))/2*a;
printf("there are real roots and they are %f and %f," root_1, root_2 );
}
return 0;
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs