That won't work. Consider the case where all five entries are equal.GopherT's initial program itself can be modified to suit the clarified requirement.
Code:for(i=0; i < 3; i++) { zeroctr = 0; for(j=i+1; j < 5; j++) { if(NumArray[i] == NumArray[j]) ++zeroctr; } if(zeroctr == 3) { // 3 & Only 3 Matches occurred. Do whatever required. } }
Also, consider the case where the first three entries are equal and the remaining ones are something else.