Sunday 21 January 2018

Program for Square root | Example Program



Program for Square root
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int a,b,c,d;
float r,r1,r2;
clrscr();
printf("enter the values a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=((b*b)-(4*a*c));
if(d==0)
{
r=-b/(2*a);
printf("roots are equal=%f",r);
}

else if(d>0)
{
r1=((-b)+sqrt(d))/(2*a);
r2=((-b)-sqrt(d))/(2*a);
printf("%f\n%f",r1,r2);
}
else
        printf("roots are imaginary");
getch();
}

0 comments:

Post a Comment