I'm trying to make a program that outputs 30 random numbers and stores them in an array, then it needs to find the average of these 30 numbers and output that back to me. So far I have this: (Sorry if I'm bad at this, I'm brand new to programming) Would appreciate any feedback :)
{
Random r = new Random();
int sum = 0;
int count = 30;
int[] numbers = new int[30] { r.Next(1, 100) };
for (int i = 0; i < 30; i++)
Console.WriteLine(r.Next(1, 100).ToString());
Console.ReadLine();
int y = r.Next();
int avg = (int)sum / count;
Console.WriteLine("The average is: {0}", avg);
Console.ReadLine();
}
Aucun commentaire:
Enregistrer un commentaire