So basically what I need to do is create an array, have the user populate the array, then I just bubble sort the array. I have the basic idea of the stuff i'm trying to write the issue is I keep running the program then once I enter the 10 values I get the error message " Index outside bounds of Array". I've played around with the code a bit and can't seem to crack the issue. I'm still new to this so please be patient with me.
class Program
{
public static void Main(string[] args)
{
Console.Write("\n\n");
Console.Write("Input 10 or less values then hit enter to sort values");
Console.Write("\n\n");
int[] Arr = new int[10];
for ( int i = 0; i <= 10; i++)
{
Console.Write("Input Value\n");
Arr[i] = int.Parse(Console.ReadLine());
}
for (int i = 0; i <= 10; i++)
{
for (int j = Arr.Length - 1; j > i; j--)
{
if (Arr[j] < Arr[j - 1])
{
var temp = Arr[j];
Arr[j] = Arr[j - 1];
Arr[j - 1] = temp;
}
}
}
foreach (int i in Arr)
{
Console.WriteLine(i);
}
Console.Read();
}
}
}