I want to create a loop that prints out a diffrent random number 10 times. I tried creating a random int in the variable num and then used a for-loop that printed out the variable num 10 times:
Random rnd = new Random();
int num = rnd.Next(10);
for (int i = 0; i < 10; i++)
{
Console.WriteLine(num)
}
This obviously doesn't work since it prints out the same random number 10 times. How do I get it to output a diffrent number in each loop?
Aucun commentaire:
Enregistrer un commentaire