'Simple calculator in c with brackets

I tried to make simple calculator in c supporting +, -, * and / operators with brackets. For example ((2.1 - 5.6)*4)+(2.8+2 / 2.2) should be -10.29... I tried like this but it works only with out barckets. I have no idea how to deal if the user's input includes brackets.

float calc(void)
{
    float x,y, parse;
    char c;

    int test = scanf("%f %c %f", &x,&c,&y);
    if (test == 0){ // if '(' starts equation
        parse = calc();
        }

    else{
        if (c == '-'){
            return x - y;
        }
        else if (c == '/'){
            return x / y;
        }
        else if (c == '+'){
            return x + y;
        }
        else if (c == '*'){
            return x * y;
        }
    }
}


Solution 1:[1]

Here you have the algorithm: http://en.wikipedia.org/wiki/Shunting-yard_algorithm

What you are using is called infix notation by the way. What the algorithm seems to do is to transform this into postfix notation (which is much more easy to compute since you just need a stack).

Solution 2:[2]

You cannot solve an equation that complicated with brackets in this simple way. There are some algorithms that you have to follow. One of them which is used in some calculators is Reversed Polish Notation where you transform the equation into a specific form, then using a stack you start pushing and popping to do the calculation taking into consideration priorities.

Link to Reverse Polish Notation

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 CMPS