C language: Calculate the heel of the quadratic equation of a. The coefficients a, B, and c are input by the keyboard.

Source: Internet
Author: User

C language: Calculate the heel of the quadratic equation of a. The coefficients a, B, and c are input by the keyboard.
Calculate the following of the quadratic equation of a, B, and c from the keyboard input program:

# Include <stdio. h> # include <math. h> int main () {double a, B, c, d, p, q, x1, x2; printf ("Enter the value of a, B, c :"); scanf ("% lf", & a, & B, & c); d = B * B-4 * a * c; if (d> = 0) {p =-B/(2.0 * a); q = sqrt (d)/(2.0 * a); x1 = p + q; x2 = p-q; printf ("x1 = % lf \ nx2 = % lf \ n", x1, x2 ); // use lf to output the decimal part with 6 digits/* printf ("x1 = % 7.2f \ nx2 = % 7.2f \ n", x1, x2 ); * // The specified output data occupies 7 columns and the decimal number occupies 2} else {printf ("the original equation has no real number solution \ n");} return 0 ;}

 

Result: Enter the values of a, B, and c: 2 3 1x1 =-0.500000x2 =-1.000000. Press any key to continue...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.