Tuesday, 18 August 2015

Programming in C to find the value of any variable using Quadratic Equation.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d,e,f,g,x,x1,x2;
clrscr();
printf("Enter the value of a,b,c respectively\n");
scanf("%d %d %d",&a,&b,&c);
if (b<a,b<c)
{
printf("Please input right value of a,b and c\n Please try again\n\n Value should be positive under root\n Value of b is always greater than others");
}
else
{
d=(b*b)-(4*a*c);
e=sqrt(d);
f=-b+e;
g=-b-e;
x1=f/(2*a);
x2=g/(2*a);
printf("Two values of x are:\n");
printf("%d and %d",x1,x2);
}
getch();
}

No comments:

Post a Comment