当前位置:网站首页>Application of quadratic function

Application of quadratic function

2020-12-06 20:48:22 Piglets need to learn programming

#include<stdio.h>
#include<math.h>
int main(void)
{
    float a, b, c, delta, x1, x2;//x1,x2 The value is the output 
    printf("a=");
    scanf_s("%f", &a);
    printf("b=");
    scanf_s("%f", &b);
    printf("c=");
    scanf_s("%f", &c);
    delta = b * b - 4 * a * c;
    if (delta >= 0)
    {
        printf(" There are real roots ");
    }
    else
    {
        printf(" There are no real roots ");
    };
    x1 = (-b + sqrt(delta)) / (2 * a);
    x2 = (-b - sqrt(delta)) / (2 * a);
    printf("x1=%f", x1);
    printf("x2=%f", x2);
}

版权声明
本文为[Piglets need to learn programming]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201206203921041o.html