/*Hello!! I'm aditya From Bangalore I have the solution of this program*/
#include <stdio.h>
#include <math.h>
main()
{
float a,b,c,x1,x2,delta=0;
printf("enter the value of a,b,c\n");
scanf("f%f",&a,&b,&c);
delta=((b*b)-(4ac));
if(a=0)
{
printf("the variables cannot form a quadratic equation\n");
}
else
{
x1=(-b)+(sqrt(((b*b)-(4ac))/2a))
x2=(-b)-(sqrt(((b*b)-(4ac))/2a))
}
if(delta=0)
{
printf("the roots are real and equal");
}
if(delta>0)
{
printf("the roots are real and distinct");
}
if(delta<0)
{
printf("the roots are imaginary");
x1=(-b)+(sqrt(((b*b)-((4ac))/(float)(2a))
x2=(-b)-(sqrt(((b*b)-((4ac))/(float)(2a))
}
printf("the roots of the equation are %2.2f\n",x1,x2,delta);
}
/*the program is written by using simple-if and if-else constructs*/
(Uses Square Root Function) PRINT "Ax^2 + Bx + C = 0" INPUT "A = ", A INPUT "B = ", B INPUT "C = ", C D = B * B - 4 * A * C IF D > 0 THEN DS = SQR(D) PRINT "REAL ROOTS:", (-B - D) / (2 * A), (-B + D) / (2 * A) ELSE IF D = 0 THEN PRINT "DUPLICATE ROOT:", (-B) / (2 * A) ELSE DS = SQR(-D) PRINT "COMPLEX CONJUGATE ROOTS:", (-B / (2 * A)); "+/-"; DS / (2 * A); "i" END IF END IF
READ values of a, b and c,if a is zero then stop as we do not have a quadratic,calculate value of discriminantif D is zero then there is one root: ,if D is > 0 then there are two real roots: and ,if D is < 0 there are two complex roots: and ,PRINT solution.
#include <stdio.h> #include <conio.h> #include <math.h> void main() { float a, b, c; float root1, root2,de,d; printf("enter the values of a, b and c"); scanf("%f%f%f", &a,&b,&c); de=(b*b)-4*(a*c); d=sqrt(de); root1=(-b+d) /(2.0*a); root2=(-b-d) /(2.0*a); printf(" roots of the equation are %f %f", root1,root2); getch(); }
#include<stdio.h> #include<conio.h> void main() { float a,b,c,z,d,x,y; clrscr(); printf("Enter the value of a,b,c"); scanf("%f %f %f",&a,&b,&c); d=((b*b)-(4*a*c)); z=sqrt(d); x=(-b+z)/(2*a); y=(-b+z)/(2*a); printf("The Quadratic equation is x=%f and y=%f",x,y); getch(); } This answer does not think about imaginary roots. I am a beginner in C programming. There might be flaws in my code. But, it does well. the code is #include<stdio.h> #include<math.h> main() { float a, b, c; float dis, sqdis, real, imag, root1, root2; printf("This program calculates two roots of quadratic equation of the form ax2+bx+c=0.\n"); printf("\n"); printf(" please type the coefficients a, b and c\n"); printf("\n"); printf("a = "); scanf("%f", &a); printf("\n"); printf("b = "); scanf("%f", &b); printf("\n"); printf("c = "); scanf("%f", &c); printf("\n"); dis = (b*b-4*a*c); if(dis < 0) { sqdis = sqrt(-dis); real = -b/(2*a); imag = sqdis/(2*a); printf(" The roots of the quadratic equations are \n x1\t=\t %f + %f i\n x2\t=\t %f - %f i\n", real, imag, real, imag); } else { sqdis = sqrt(dis); root1 = -b/(2*a)+sqdis/(2*a); root2 = -b/(2*a)-sqdis/(2*a); printf("The two roots of the quadratic equations are %f and %f.\n", root1, root2); } system("pause"); }
First, we assume you are asking for the resistance of the bulb. Second, there can be only one possible resistance. The bulb has one and only one resistance. The equation for solving this problem may be a quadratic or even a cubic equation, which may have multiple roots, but only ONE can be a real-world answer. Third, let's list everything we know about the circuit. Let's label the power source Vcc. We'll label the known resistor R, and the resistance of the bulb Rb. We'll label the power dissipated by the bulb as simply P. We'll also label the current flowing through the bulb as I. What do we know about power? The power dissipated by a resistor is given by three well-known formulas: P = IV, P = I2R, or P = V2/R. (The second and third are derived from the first.) The second one will come in handy for us right now. We can write: [Equ. 1] P = I2Rb What else do we know? Since it's a series circuit, the current flowing through the bulb, I, is the same as the current flowing through the resistor. And we know from Ohm's Law that I = V/RT, where RT is the sum of the two resistances in the circuit: R + Rb. So, we can write: [Equ. 2] I = Vcc/(R + Rb) So, substituting for I in Equ. 1 with the I we found in Equ. 2 we have: P = [Vcc/(R + Rb)]2Rb = [Vcc2/(R + Rb)2]Rb = Vcc2Rb/(R2 + 2RRb + R2b) Phew! The algebra's getting a bit hairy. We need to do a few more manipulations. We can swap the P on the left side of the equal sign with the denominator of the fraction on the right side of the equal sign, so we write: R2 + 2RRb + R2b = Vcc2Rb/P We now multiply both sides of the equation by P and we write: PR2 + 2PRRb + PR2b = Vcc2Rb Stay with me now; we're almost there. If we subtract Vcc2Rb from both sides and gather similar terms, we can write: PR2b+ (2PR - Vcc2)Rb + PR2 = 0 We can now substitute all the known values into the equation above. We know Vcc = 131, R = 133, and P = 22.9. So, we can write: 22.9R2b - 11070Rb + 405078 = 0 So, we have quadratic equation, which will have two roots for Rb. Using the quadratic formula, we determine that there are two real roots: Rb = 443.5 and 39.9. The second result is thrown out since it is not consistent with Equ. 1 and Equ. 2.
Write an algorithm to find the root of quadratic equation
2000X=Y2KoverZzz?
Write the quadratic equation in the form ax2 + bx + c = 0 The roots are equal if and only if b2 - 4ac = 0. The expression, b2-4ac is called the [quadratic] discriminant.
dejene
That depends on the equation.
If the discriminant of the quadratic equation is zero then it will have 2 equal roots. If the discriminant of the quadratic equation is greater than zero then it will have 2 different roots. If the discriminant of the quadratic equation is less than zero then it will have no roots.
The easiest way to write a generic algorithm is to simply use the quadratic formula. If it is a computer program, ask the user for the coefficients a, b, and c of the generic equation ax2 + bx + c = 0, then just replace them in the quadratic formula.
Because it's part of the quadratic equation formula in finding the roots of a quadratic equation.
Write the quadratic equation in the form ax2 + bx + c = 0 then the roots (solutions) of the equation are: [-b ± √(b2 - 4*a*c)]/(2*a)
Yes. You can calculate the two roots of a quadratic equation by using the quadratic formula, and because there are square roots on the quadratic formula, and if the radicand is not a perfect square, so the answer to that equation has decimal.
Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.
2 roots