// Q equ //
#include <stdio.h>
#include <math.h>
void main()
{
double a,b,c ; // i use this for 0.000 real
double m,n,r ;
double real,imgn ;
printf ("enter var A ") ;
scanf ("%f", &a) ;
printf ("enter var B ") ;
scanf ("%f", &b) ;
printf ("enter var C ") ;
scanf ("%f", &c) ;
r = ( (b*b)-(4*a*c) ) ; /* for specific = 0 , >0 , <0
two sismilar solution , tow difrent solution , comlix root & number */
if (r>=0)
{
m= ( (-b) + sqrt(pow(b,2) - (4*a*c)) ) / (2*a) ;
n = ( (-b) - sqrt(pow(b,2) - (4*a*c)) ) / (2*a) ;
printf ("X1 = %7.3f \n",m ) ;
printf ("X2 = %7.3f \n",n ) ;
}
else
{
printf ("complex root \n") ;
real = (-b)/(2*a) ;
imgn = sqrt(-r) /(2*a) ;
// 7.3 refer to 000.000
printf ("X1 = %7.3f + %7.3f i \n",real,imgn) ;
printf ("X2 = %7.3f - %7.3f i \n",real,imgn) ;
}
}
The most beautiful thing we can experience is the mysterious, it is the source of all true art and science.
Imagination is more important than knowledge.
Wednesday, November 19, 2008
Quadratic equation in C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment