0
I’m trying to solve an exercise that’s like this:
Make an algorithm that reads the height and enrollment of ten students. Show the enrollment of the highest student and the lowest student
And my code right now is like this:
Console.WriteLine("Altura dos Alunos");
for ( int i = 0; i <= 10; i++)
{
Console.WriteLine("Qual a sua altura: ");
double altura = Convert.ToDouble(Console.ReadLine ());
Console.WriteLine("Qual sua matrícula? Ex: 1234");
int matricula = Convert.ToInt32(Console.ReadLine());
double altura2 = 0;
Math.Max( altura, altura2 );
altura2 = altura;
}
Like I use the method Math.Max()
to take the higher height and show it later without me having to create 10 variables?
first you need to have where to store the ten students...
– Rovann Linhalis
Then I will have to create 10 variables even to store the height and then use Math.Max?
– Pseudoser
it is more likely that this is an exercise using arrays, so you only declare an array with 10 positions
– Rovann Linhalis