How to find the sum of numbers that have digits higher than 5 : <p>so I want to write a function that returns the sum of all numbers in an array who's digits are higher then 5 so for example if the array is [12, 66, 23, 67] the answer would be 66+67
This code summs all the numbers in the array and I can'\t figure out why</p>

<pre><code>
using namespace std;
int func(int n[], int size){
    int digit, S=0, a;

    for(int i=0; i&lt;size; i++){

      a= n[i];

        while( n[i]!=0){

            digit= n[i]%10;

                  if(digit&gt;=5){

                       n[i]= n[i]/10;


                    }
         else break;

        }
        S=S+a;

    }

 return S;   
}

int main()
{
    int n[3], i;

   for(int i=0; i&lt;3; i++){
       cin&gt;&gt;n[i];


   }

   cout&lt;&lt;func(n, 3)&lt;&lt;endl;
    return 0;
}```

</code></pre>
