codes for solution of quadratic equations.

#include <stdio.h>
#include <math.h>
void main()
{
    //@codewithsandhan
    float a, b, c, x, D, x1, x2;
    printf("\n\n     \U0001F637   SOLUTIONS OF QUADRATIC EQUATION OF SINGLE VARIABLR  !!!!\n\n\n");
    printf("     \U0001F917   Equation should be like     ax^2 + xb + c = 0   \n\n\n  ");
    printf("         \U0001F600   Enter the value of a : ");
    scanf("%f", &a);
    printf("\n           \U0001F600     Enter the value of b : ");
    scanf("%f", &b);
    printf("\n           \U0001F600    Enter the value of c : ");
    scanf("%f", &c);
    printf("\n\n");
    x = (b * b) - (4 * a * c);
    if (x > 0)
    {
        x1 = (-b + pow(x, 0.5)) / (2 * a);
        x2 = (-b - pow(x, 0.5)) / (2 * a);
        printf(" \n     \U0001F616    roots are real and distincts .\n\n");
        printf("\n\n   \U0001F618  x1 =%.3f      \U0001F618   x2 = %.3f\n", x1, x2);
    }
    if (x < 0)
    {
        x1 = (pow(-x, 0.5)) / (2 * a);
        printf(" \n   \U0001F616   roots are imagenary and distincts .\n");
        printf("\n\n   \U0001F618   x1 =%.2f+%.3f i   \U0001F618     x2 = %.2f-%.3f i\n\n", -b / 2, x1, -b / 2, x1);
    }
    if (x == 0)
    {
        printf("   \U0001F616   Roots are same :  \n   ");
        printf("  \n\n   \U0001F618   x1 = x2 = %.2f", -b / (2 * b));
    }
    printf("%f", D);
}

Comments