-->
Showing posts with label simple technique. Show all posts
Showing posts with label simple technique. Show all posts

program to get values in of x in quadratic equation

//program to get values of x in quadratic equation
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,x1,x2;
printf("enter values of a,b and c\n");
scanf("%f%f%f",&a,&b,&c);
x1=(-b+sqrt(b*b-4*a*c))/2*a;
x2=(-b-sqrt(b*b-4*a*c))/2*a;
printf("the first value=%f\n",x1);
printf("second value is=%f",x2);
getch();
}

note:

according to formula the condition should be satisfied.like
1) (b2-4ac)>0 i.e. b2>4ac
2)a>0 for 2a
otherwise the program terminates abnormally without any result.
later we will see this program with 'if' structure'.

Logically that is said to be right.