Just reverse sort the array by grade, and don't write anyone who failed down in the printing phase.

Since we're talking about grammar now, you can do the first clause with qsort, and the other with a loop and an if statement.