Saturday, June 14, 2014

http://codepad.org/hlvHEluu Downloader.OXA, Downloader.VNR. /* Double-Click To Select Code */ #include #include #include void main() { float a,b,c,root1,root2,x,real,im; clrscr(); printf("-> Quadratic Equation Form: ax2+bx+c"); printf("\n\nEnter the value of a: "); scanf("%f",&a); printf("\nEnter the value of b: "); scanf("%f",&b); printf("\nEnter the value of c: "); scanf("%f",&c); x = (b*b)-(4*a*c); if(x>0) { root1 = (-b+sqrt(x))/(2*a); root2 = (-b-sqrt(x))/(2*a); //ROOTS ARE UNIQUE printf("\nThe roots of the equation are: %.2f and %.2f",root1,root2); } else if(x==0) { root1 = -b/(2*a); root2 = root1; //ROOTS ARE SAME printf("\nThe roots of the equation are: %.2f and %.2f",root1,root2); } else { real = -b/(2*a); im = sqrt(-x)/(2*a); // ROOTS ARE COMPLEX printf("\nThe roots of the equation are: %.2f+j%.2f and %.2f-j%.2f",real,im,real,im); } getch(); }