Let $n$ be a positive integer. What is the largest $k$ for which there exist $n\times n$ matrices $M_1,\dots,M_k$ and $N_1,\dots,N_k$ with real entries such that for all $i$ and $j,$ the matrix product $M_iN_j$ has a zero entry somewhere on its diagonal if and only if $i\ne j?$
1. **Reformulate the problem in terms of tensor products:**
   We need to find the largest \( k \) such that there exist \( n \times n \) matrices \( M_1, \ldots, M_k \) and \( N_1, \ldots, N_k \) with real entries satisfying the condition that \( M_i N_j \) has a zero entry on its diagonal if and only if \( i \ne j \).

2. **Define the function \(\phi\):**
   Consider the function \(\phi: \prod_{i=1}^{n} \mathbb{R}^n \times \prod_{i=1}^{n} \mathbb{R}^n \to \mathbb{R}\) defined by
   \[
   \phi \left( (u_1, \ldots, u_n), (v_1, \ldots, v_n) \right) = \prod_{i=1}^{n} (u_i \cdot v_i),
   \]
   where \( u_i, v_j \) are vectors in \( \mathbb{R}^n \) and the dot denotes the scalar product.

3. **Linear properties of \(\phi\):**
   The function \(\phi\) is linear in each of the \( u_i \) and \( v_j \). Hence, \(\phi\) is a multilinear map and defines a well-defined map in the tensor product space \( T = \bigotimes_{i=1}^{n} \mathbb{R}^n \).

4. **Restate the problem using tensor products:**
   The problem now becomes: Let \( M_1, \ldots, M_k \) be elementary tensors in \( T \) for which there exist elementary tensors \( L_1, \ldots, L_k \) in \( T \) such that
   \[
   \phi(M_i \otimes L_j) = 0 \quad \text{iff} \quad i \ne j.
   \]

5. **Linear independence of \( M_i \):**
   The \( M_i \) form a linearly independent set. This can be seen by taking any linear relation among the \( M_i \) and applying \(\phi(\cdot \otimes L_j)\) for all \( 1 \le j \le k \).

6. **Dimension of the tensor product space:**
   Since the dimension of \( T \) is \( n^n \) (because the tensor product of free modules is free), we must have \( k \le n^n \).

Conclusion:
\[
\boxed{k \le n^n}
\]