I am trying to run this code and eveything runs fine till the program has to write the answer from the question. i Keep getting a SystemIndexOutOfRangeException.
I dont seem to get this issue when i input the number 5, 6, 2 but anything else and i get this exception
static void Question1()
{
Console.WriteLine("Question 1");
Console.WriteLine("----------------------------------------------------------------------");
Console.WriteLine();
int[] a = new int[] { 5, 7, 8, 3, 25, 10, 90 };
int[] b = new int[] { 78, 6, 4087, 2, 2, 2, 6 };
int[] c = new int[] { 2, 2, 3, 6, 5, 8, 90 };
int aValue;
int bValue;
int cValue;
Console.WriteLine("Array A = [{0}]", string.Join(", ", a));
Console.WriteLine("Array B = [{0}]", string.Join(", ", b));
Console.WriteLine("Array C = [{0}]", string.Join(", ", c));
Console.WriteLine();
Console.WriteLine("Enter a positional value of Array A");
aValue = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter a positional value of Array B");
bValue = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter a positional value of Array C");
cValue = Convert.ToInt32(Console.ReadLine());
Console.WriteLine($"{a[aValue]} plus {b[bValue]} times {c[cValue]} = {a[aValue] + b[bValue] * c[cValue]} ");
Console.WriteLine($"{a[aValue]} plus {b[bValue]} times {c[cValue]} = {(a[aValue] + b[bValue]) * c[cValue]} ");
Console.ReadKey();