+ 2
Random numbers in C
Is there any possibility of get a random number as output from a range of integers in C? Considering that the output are not static (e.g.: in a range [1,100] the first number is always 64)
2 Antworten
+ 6
using
srand(time(NULL);
rand()%100+1;
will give you the desired result you need
+ 3
#include <time.h>
time_t t
srand(time(&t))
https://code.sololearn.com/c4g8TtezZhZb/?ref=app
https://code.sololearn.com/cMlkxLKw1wov/?ref=app