In this video, see a solution to this chapter's challenge.
(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 the variable I will be assigning a random…
- Working with header files
- C constants and types
- Unformatted and formatted input/output
- Accessing files with C functions
- Generating random numbers
- Converting strings
- Sorting and searching for data
- Manipulating strings
- Using mathematical functions
Skill Level Intermediate
1. The C Standard Library
2. Input and Output Library: stdio.h
3. General Purpose: stdlib.h
4. String Functions: string.h
5. Mathematical Functions: math.h
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.