I have been working on on this problem for awhile I have two arrays in parallel that are the same length. I have nested foreach loops to compare the arrays so I can tell what number is greater. One number is randomly generated and the other is gathered from user input. The problem I'm having is the number that is randomly generated is being compared to each user input before moving to the next randomly generated number. This is my code:
Random r = new Random();
int length = 10;
int[] ranNum = new int[length];
int[] userNum = new int[length];
for (int i = 0; i < length; i++)
{
ranNum[i] = r.Next(1, 100);
}
for (int i = 0; i < length; i++)
{
Console.WriteLine("Enter a number between 1 and 100");
userNum[i] = Convert.ToInt32(Console.ReadLine());
}
foreach(int rn in ranNum)
{
foreach(int ui in userNum)
{
if (rn < ui)
{
Console.WriteLine(rn + " is less than " + ui);
}
else if (rn > ui)
{
Console.WriteLine(rn + " is greater than " + ui);
}
else
{
Console.WriteLine(rn + " is equal to " + ui);
}
}
}
I'm sure I'm missing something obvious any help would be appreciated Thank you in advance