What is rand function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

What is rand function?

how does it work?

18th May 2017, 11:11 AM
Niharika.R
Niharika.R - avatar
6 Answers
+ 14
rand function generates a random number . rand()%10 gives any random number between 0 and 9. But repeating the same code generates the same number
18th May 2017, 11:41 AM
Prabhu Nithin
Prabhu Nithin - avatar
+ 3
rand function generate pseudo-random numbers.
21st May 2017, 5:50 AM
Maheshwar Kushwaha
Maheshwar Kushwaha - avatar
+ 3
rand function returns a random number between 0 and RAND_MAX.
11th Aug 2017, 10:32 AM
Amit Singh
Amit Singh - avatar
+ 1
It is a way to produce random numbers.
18th May 2017, 11:34 AM
trevor villanueva
trevor villanueva - avatar
+ 1
Google it. there are plenty of examples out there.
18th May 2017, 11:38 AM
trevor villanueva
trevor villanueva - avatar
+ 1
This function allows you to automatically generate random numbers for your application. For instance, in a game where you have to roll a dice, you could use this function to randomly generate a number between 1 to 6 EACH time the dice is rolled by your user.
21st Jul 2017, 6:44 PM
Junaid Khalid
Junaid Khalid - avatar