From the course: C Standard Library

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Let's get random

Solution: Let's get random - C Tutorial

From the course: C Standard Library

Start my 1-month free trial

Solution: Let's get random

(upbeat music) - [Instructor] My solution is really simple. So if we take a look at the code in line 6, I am defining a symbol called total. Which I have intentionally defined as 100. That's the number of iterations I will used. And as you may expect, 100 will not yield a very nice approximation of 0.5. Remember, in this application we want to show exactly or something very close to 0.5 because that will show us the probability of getting anything less or equal than 500 in the random numbers that are generated. So that will prove us that the random number generator has a uniform distribution. And what I will do with this value is that I will compile and run for total equals 100. And I'll show you that result. Then I will increase that value, compile and run again, and I will keep showing you in proving approximations of 0.5. Once again, my program only has one main function, and what I'm doing here is that I am using a sample variable that's an integer of 32 bits unsigned and that's…

Contents