+ 3

how to use random in c language ?

4th Mar 2019, 11:56 AM
Nature_of_code
Nature_of_code - avatar
4 Antworten
+ 14
srand is generate secured random number so use of this is quite good. The function srand() is used to initialize the pseudo-random number generator by passing the argument seed. Often the function time is used as input for the seed. If the seed is set to 1 then the generator is reinitialized to its initial value. Then it will produce the results. https://www.codingunit.com/c-reference-stdlib-h-function-srand-initialize-random-number-generator srand(time(NULL)); int g = rand(); https://linux.die.net/man/3/random https://stackoverflow.com/questions/822323/how-to-generate-a-random-int-in-c/39475626#39475626
4th Mar 2019, 12:09 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 5
// use rand() function
4th Mar 2019, 12:05 PM
program
program - avatar
+ 2
We can use random generator function provided in standard library i.e stdlib.h By srand()
4th Mar 2019, 1:35 PM
Ragan Murali Pasupuleti
Ragan Murali Pasupuleti - avatar
+ 2
This code is not my original work but it is an example I looked up on Google https://code.sololearn.com/cGtCk05HS7Cq/?ref=app
5th Mar 2019, 3:59 AM
boneSpider
boneSpider - avatar