Replace with sum of greater

its not working as supposed to is it compiler error or in my code?

Modified Code

only mistake is you have to pass sum by reference