To find out how many students preferred health foods, we can use the information provided: for every ten students, two liked health foods.
First, we can set up a proportion to find the total number of students who preferred health foods out of the 50 surveyed:
\[ \text{Students who prefer health foods} = \left(\frac{2}{10}\right) \times 50 \]
Calculating the number of students who liked health foods:
\[ \left(\frac{2}{10}\right) \times 50 = 0.2 \times 50 = 10 \]
Thus, the number of students who preferred health foods is \( \boxed{10} \).