How does the random number generator work in C?

后端 未结 6 852
终归单人心
终归单人心 2021-01-23 06:29

I\'m trying to generate random number between 0 and 40(inclusive). So the code I Implemented is this-

 y=rand()%41;

However everytime I click c

6条回答
  •  盖世英雄少女心
    2021-01-23 06:55

    As for how it works, it depends. Many implementations use a Linear Congruential Generator, with different parameters.

提交回复
热议问题