+ 3

How to ask computer to randomly choose a number between 1 to 6 in C#?

10th Sep 2019, 9:10 AM
General Sam
General Sam - avatar
3 Respostas
+ 3
Random rnd = new Random(); int month = rnd.Next(1, 13); // creates a number between 1 and 12 int dice = rnd.Next(1, 7); // creates a number between 1 and 6 int card = rnd.Next(52); // creates a number between 0 and 51 int card.rnd.Next(1,7); // creates a number between 1 and 6 int
10th Sep 2019, 9:26 AM
KfirWe
KfirWe - avatar
+ 2
Please mention C# in your Relevant Tags 👍 (Edit) Tags had been adjusted.
10th Sep 2019, 9:53 AM
Ipang
+ 1
like this #include <iostream> #include <cstdlib> #include <ctime> srand(time(0)); cout << rand()%6; for C++
19th Sep 2019, 12:31 AM
Graham
Graham - avatar