Logically following your program you are on the right track. The problem is with your scoping.
The following should be taken with a grain of salt; but in C all lines either end with a semicolon or a use brackets.
For example you have
CODE
for(k=0;k<5;k++)
printf("Enter a student name : \n");
you could treat this as a single line. However, what you really wanted was:
CODE
for(k=0;k<5;k++)
{
printf("Enter a student name : \n");
scanf("%s \n",&num[k]);
}
This causes the for loop to loop on all the statements inbetween the brackets instead of just the first line like you had before.
Another interesting thing you have in your code is the following structure:
CODE
{
//code here
}
{
//code here
}
While syntatically there is nothing wrong with this; it might be confusing you. Braces like this is used to limit scope; however, because you don't declare any variables within the block, they will descope with the }. Sinse you don't declare any variables they don't do anything.
Salindor