#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");
}
You don't need a flow chart for that; just use the quadratic formula directly; most programming languages have a square root function or method. You would only need to do this in many small steps if you use Assembly programming. The formulae would be something like this: x1 = (-b + sqrt(b^2 - 4*a*c)) / (2 * a) and x2 = (-b - sqrt(b^2 - 4*a*c)) / (2 * a) where a, b, and c are the coefficients of the quadratic equation in standard form, and x1 and x2 are the solutions you want.
(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
A c program is also known as a computer program. A singular matrix has no inverse. An equation to determine this would be a/c=f. <<>> The determinant of a singular matix is zero.
/*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*/
How to write a program for secant method by mathematica
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.
Write an algorithm to find the root of quadratic equation
First, write the equation in standard form, i.e., put zero on the right. Then, depending on the case, you may have the following options:Factor the polynomialComplete the squareUse the quadratic formula
To express the equation (2x^2 + 3x + 90) in standard quadratic form, we can simply write it as (2x^2 + 3x + 90 = 0). This represents a quadratic equation where (a = 2), (b = 3), and (c = 90). The equation can be solved for (x) using the quadratic formula or factoring, if applicable.
to solve ax2 + bx + c use the quadratic formula: (-b +/-(b2 - 4ac))/2a. Programming this should be a doddle.
2000X=Y2KoverZzz?
readuse the answer
An example of a quadratic equation is ( ax2 bx c 0 ), where ( a ), ( b ), and ( c ) are constants and ( x ) is the variable.
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.
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)
computer scince
ax2 + bx + c