Use of struct to display student who are in top 5
i wnt to display student who get highest marks among them...i have code for finding maximum marks from them but don't kne how to print only top 5 student...so plz help me:(
Code:
static void Main(string[] args)
{
Console.WriteLine("Please Enter Number of Students :");
int n = Convert.ToInt32(Console.ReadLine());
StudentDetails[] student = new StudentDetails[n];
for (int row = 0; row < n; row++)
{
Console.WriteLine("Please Enter Student name :");
student[row].name = Console.ReadLine();
Console.WriteLine("Please Enter Student Marks :");
student[row].mark = Convert.ToInt32(Console.ReadLine());
}
int max = student[0].mark;
for (int row = 0; row < n; row++)
{
if ( student[row].mark > max)
max = student[row].mark;
}
for (int row = 0; row < n; row++)
{
Console.WriteLine();
Console.WriteLine("-----------------------------");
Console.WriteLine("Details of Student: " + (row + 1));
Console.WriteLine("Student Name= " + student[row].name);
Console.WriteLine("Student Mark= " + student[row].mark);
}
Console.ReadLine();
}
}
(dis code in Visual Studio)