#include <stdio.h>
#include "libs.h"
//---------------------------------------------------------------------------------------
//                                              Exercise 3
//                                              ----------
//
// General : The program performs the formula of the roots.
//
// Input   : 3 numbers (a,b,c from ax^2+bx+c).
//
// Process : The program performs the formula of the roots.
//
// Output  : 2 numbers (sign and result).
//
//---------------------------------------------------------------------------------------
// Programmer : Cohen Idan
// Student No : None
// Date       : 12.09.2019
//---------------------------------------------------------------------------------------
void main(void)
{
    short num_a,
          num_b,
          num_c,
          delta,
          sign = ONE,
          result = ZERO;

    printf("Enter a,b,c from ax^2+bx+c: ");
    scanf("%hd%hd%hd", &num_a, &num_b, &num_c);

    // Calculate delta
    delta = (num_b * num_b) - (FOUR * num_a * num_c); 
    result = -num_b / TWO * num_a;
    if (delta > ZERO)
    {
        sign = TWO;
        result = ZERO;
    }
    if (delta < ZERO)
    {
        sign = ZERO;
        result = ZERO;
    }

    printf("If you got sign '0' - not result\n\
If you got sign '1' - one result\n\
If you got sign '2' - two results:\nSign: %hd\nResult: %hd\n", sign, result);
}