Simple: if you uncomment the line, then every time it doesn't find a match, it sets the flag to "no match". Which means that if you find a match in the first location, you set the "found it" flag, and overwrite it back to "not found" for every other character in the array.
The best solution to this is simple: exit from the loop when you find a match:
int main()
{
int a[]={2,5,8},i,n=2
for(i=0;i<10;i++)
{
if(a[i] == n )
{
printf("present %d\n",n);
break;
}
}
}