This code how to find the smallest number.
My question is now how to find the largest number?
int iSmallest = int.MaxValue;
int iSmallestLocation = 0;
int[] iArray = new int[5];
for (int i = 0; i < iArray.Length; ++i)
{
Console.Write("\nEnter a value: ");
iArray[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine();
foreach(int iValue in iArray)
Console.Write("{0}, ", iValue);
for (int i = 0; i <
iArray.Length; ++i)
{
if (iArray[i] > iSmallest)
{
iSmallest = iArray[i];
iSmallestLocation = i;
}
}
Console.WriteLine("\nThe lowest number is at location {0} and is {1}",
iSmallestLocation, iSmallest);
Console.ReadKey();