The function $f()$ is checking if the random integer generated by $rand()$ is odd. The expression $n&1$ is used for checking the parity of $n$ (odd or even), so $f()$ returns $1$ if the random number is odd and return $0$ otherwise.
Now inside the for loop, the variable $count$ is incremented only if both the $f()$'s inside the if condition are true. This happens when $2$ odd random numbers are generated.
For calculating the expected value of $count$, let us have an indicator random variable $X_i$, such that $X_i = 1$ if $count$ is incremented at the $ith$ iteration in the loop and $X_i = 0$ otherwise. Then $E[Xi] = P(Xi) = 1/4$ (Odd Even, Even Odd, Odd Odd, Even Even There are 4 possibilities. Favorable case is Odd Odd) The expected value of $count$ call this $E[Z]$ is given by $E[Z] = E[X1] + E[X2] + E[X3] + ... + E[XN]$. So $E[Z] = N * 1/4 = N/4$