random sequence | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

random sequence

rand() in other words called as in c# and Java

6th May 2017, 10:58 AM
Abraham Ram Rebello
Abraham Ram Rebello - avatar
2 Answers
+ 3
int max , min; in c# Random r = new Random (); r.next(min,max); or simply r.next(); for java one way import java.util.Random; Random rand = new Random(); int n = rand.nextInt(max) + min; another way int random = (int )(Math.random() * 50 + 1); to select between 50 and 1
6th May 2017, 11:02 AM
MR Programmer
MR Programmer - avatar
+ 7
Yes. But rand() isn't the best for c++. Try using random generation functionality found in the header file <random> Here is some examples of its usage. https://code.sololearn.com/cd91tzFJGYO7/?ref=app https://code.sololearn.com/cZtmt5Apo0tf/?ref=app
6th May 2017, 11:05 AM
jay
jay - avatar