> I took out return r and I get an error on line 20 "control reaches end of non-void function"
You mean you didn't consider say
stud = allocate();
in main?

Another question.

If you had
struct student students[10];
in place of calling malloc, could you solve the rest of the problem?