Choices of $k$ out of $n$ correspond to ordered $k+1$-tuples of nonnegative numbers which add up to $n-k$ by counting the dots between the Xs. The number of such $k+1$-tuples so that $a$ particular terms are at least $q$, with no restrictions on the others, is $n-aq \choose k$, since subtracting $q$ from each of the terms we know are at least $q$ gives an unrestricted $k+1$-tuple adding to $n-aq$. So, the technique of inclusion-exclusion lets us count $f(n,k,q)$, the number of $k+1$-tuples with no term which is at least $q$: $$ f(n,k,q) = \sum_{a=0}^{k+1} (-1)^a {k+1\choose a}{n-aq\choose k}.$$ To count sequences where the maximum is exactly $q$, take $f(n,k,q+1)-f(n,k,q)$.