Why my code is wrong?

this is sum.


this is my code

Hey @dhruvilcodes
Include this header for intmin and intmax

#include<climits>

If this resolves your query then please mark it as resolved :slight_smile:

but in hacker rank 1 testcase giving wrong please help

Hey @dhruvilcodes
Not working for this testcase
5 5 5 5 5

So to rectify the problem
from total sum subtract minimum for maxiimum value
and for minimum value subtract maximum
Instead of doing this

    for (i = 0; i < n; i++)
    {
        if (a[i] != k)
        {
            sum1 = sum1 + a[i];
        }
        if (a[i] != j)
        {
            sum2 = sum2 + a[i];
        }
    }
1 Like

okay got it thank you

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.