Hi guys i m new around here as you can see,
i was wondering why can t the program find
the minimum of random generated numbers?Any
help would be greatly apreciated.
public static void Main(string[] args)
{
int[] randomNum = new int[10];
int min = randomNum[0];
int max = randomNum[0];
Random RandomNumber = new Random();
Console.WriteLine("Printing the interval");
Console.WriteLine("---------------------------");
foreach (int i in randomNum)
{
randomNum[i] = RandomNumber.Next(1, 10);
Console.WriteLine(randomNum[i]);
if (randomNum[i] > max)
{
max = randomNum[i];
}
else if (randomNum[i] < min)
{
min = randomNum[i];
}
}
Console.WriteLine("---------------------------");
Console.WriteLine("Maximal number is in interval <1,10> \t"+max);
Console.WriteLine("Minimal number is in interval <1,10> \t"+min);
Console.ReadLine();
}
} `