Getting the Sum of Discounted Price Jojo is browsing the internet while suddenly he sees an ad about the new cafe. The promotion is if the price
of an item is N dollars, then you can buy the second item for half the price, the third item for a quarter of the
original price, and so on, but if it becomes less than M dollars, then you have to pay M dollars. He wonders
how much he has to pay if he buys K item.



Format Input

The first line will contain an integer T, the number of test cases.
Each test case will have 3 integers N, M, and K, each denoting the original price, the minimum price, and the
amount Jojo is going to buy.

Format Output

For each test case, print “Case #X: “ (X starts with 1), then followed by the price Jojo has to pay rounded to 3
decimal digits.

Constraints

1 &lt;= T &lt;= 10

1 &lt;= M &lt;= N &lt;= 1,000,000,000

1 &lt;= K &lt;= 1,000,000,000    

#include &lt;stdio.h&gt;

    int main()
    {
        int T;
        scanf("%d", &amp;T);

        for (int i = 1; i &lt;= T; i++) {
            int M, K, N;
            scanf("%d %d %d", &amp;N, &amp;M, &amp;K);

            float halfPrice = N;
            float sum = halfPrice;

            for (int j = 0; j &lt; K-1; j++) {
                halfPrice /= 2;
                halfPrice = (halfPrice &lt; M) ? M : halfPrice;
                sum += halfPrice;
            }
            printf("Case #%d: %.3f\n", i, sum);
        }
    }
Formatting
This may be a copy and paste error, but generally int main() will start in the first column like the #include does. Other the rest of the indentation needs to be based on that. This was correctly done in your earlier question.

#include &lt;stdio.h&gt;

int main()
{
    int T;
    scanf("%d", &amp;T);

    ...

}


Functions
You may not have run into difficult problems yet, but as the programs get more complex the best way to solve them will be to break it up into smaller pieces where each particular task is easy to solve. In this case the outer for loop would make a good function. Perhaps the inner loop would make a second good function.

Variable Names
Variable names should be meaningful to make the code more readable, easier to understand and maintainable.

The problem statement gives you the variable names T, N, M and K which are currently being used in the code, however, it also gives you what the variables are used for. It might be better to use names such as testCount for T, maxPrice for N, minPrice for M and itemCount for K.

The variable name halfPrice could be misleading be it won't always be half of the maximum price.

Mixing Types in Comparisons
There is the possibility of Floating Point Error in the code because of this comparison: 

            halfPrice = (halfPrice &lt; M) ? M : halfPrice;


While the minimum price is input as an integer it might be better to convert it to a float and use that in the comparison. This conversion should only be done once per test case.

In many cases banks work around this by keeping amounts in 2 integer values, one for dollars and one for cents (units are USA, units may differ based on location).