#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,r1,r2,d;
clrscr();
printf("\n enter values of a,b,c:");
scanf("%f%f%f",&a,&b,&c);
if(a==0)
printf("enter value should not be zero");
else
{
d=b*b-4*a*c;
if(d>0)
{
r1=-b+sqrt(b*b-4*a*c)/2*a;
r2=-b-sqrt(b*b-4*a*c)/2*a;
printf("roots are real and unequal \n");
printf("r1=%f\n r2=%f",r1,r2);
}
else
{
if(d==0)
{
r1=-b/(2*a);
r2=-b/(2*a);
printf("\n roots are real and equal");
printf("\n root=%f\n",r1);
printf("\n root=%f\n",r2);
}
else
printf("roots are imaginary");
}
}
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,r1,r2,d;
clrscr();
printf("\n enter values of a,b,c:");
scanf("%f%f%f",&a,&b,&c);
if(a==0)
printf("enter value should not be zero");
else
{
d=b*b-4*a*c;
if(d>0)
{
r1=-b+sqrt(b*b-4*a*c)/2*a;
r2=-b-sqrt(b*b-4*a*c)/2*a;
printf("roots are real and unequal \n");
printf("r1=%f\n r2=%f",r1,r2);
}
else
{
if(d==0)
{
r1=-b/(2*a);
r2=-b/(2*a);
printf("\n roots are real and equal");
printf("\n root=%f\n",r1);
printf("\n root=%f\n",r2);
}
else
printf("roots are imaginary");
}
}
getch();
}
No comments:
Post a Comment