![]() ![]() ![]() If the discriminant is greater than 0, the roots are real and different.The term b 2 - 4ac is known as the discriminant of a quadratic equation. The standard form of a quadratic equation is: ax 2 bx c = 0, where Note: The ‘ << endl ‘ in the code is used to end the current line and move to the next line and ‘\n’ is also a new line function, to understand how both the functions work exclude it from the code, move it around and work with it.C program to find root of a quadratic equation Through this tutorial, you will learn how to find the root of a quadratic equation in c program. When you look at the last output statement, is should be displayed as x1 = -0.5 0.866025iand x2 = -0.5-0.866025i and hence the statement cout The realPart and the imaginaryPart are just variables which holds the answer after the function is executed. And for the last condition if determinantelse if (discriminant = 0) – this statement’s formula as in the above image is written as x1 = -b/(2*a).In this the sqrt function is used to find the square root of a number. if (discriminant > 0) – this statement’s formula, as in the above image is written as x1 = (-b sqrt(discriminant)) / (2*a) and x2 = (-b - sqrt(discriminant)) / (2*a).If both these conditions are not satisfied the next else statement is executed. ![]() The int main()shows that the input value is a type of integer, once the program is executed the function returns to the main function, by using the statement ‘return 0 ’.This line usually controls the function of the code, as it calls the functions to perform their tasks.The C has a standard library that has files for different functions and this line is used to access the standard file for input and output statements.The file declares a set of functions to perform mathematical operations.The file stands for Input and Output statement. #include statement tells the compiler to use available files and is the name of the specific that we have used in this code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |