I am still having slight troubles with functions and arrays. I have created an array that has been filled with random numbers. I am trying to create a function that sets up the array and returns the highest value. I am not to sure on how to approach this but this and what I have written so far has not been able to compile.
namespace Task_1._13
{
class Program
{
static void Main(string[] args)
{
gettingMaximum(int i);
}
public int gettingMaximum(int i);
{
int maximum = 0;
int[] myArray = new int[10];
Random rand = new Random();
for (int i = 0; i < myArray.Length; i++)
{
myArray[i] = rand.Next(19);
}
for (int i = 0; i < 10; i++)
{
if (i == 0)
maximum = myArray[i];
else
if (myArray[i] < maximum) maximum = myArray[i];
int result = i;
return result;
}
}
}
}
That's what I have gotten so far. I am not very experienced in programming so help would be appreciated.
int i, and then try to re-declare it in the for loopmaximum = myArray[0]before the loop. The second is that you are returning your result inside of your loop. Think about how that will work.