O'Reilly logo

Advanced Topics in C: Core Concepts in Data Structures by Noel Kalicharan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 7

image

Random Numbers, Games, and Simulation

In this chapter, we will explain the following:

  • Random numbers
  • The difference between random and pseudorandom numbers
  • How to generate random numbers on a computer
  • How to write a program to play a guessing game
  • How to write a program to drill a user in arithmetic
  • How to write a program to play Nim
  • How to simulate the collection of bottle caps to spell a word
  • How to simulate queues in real-life situations
  • How to estimate numerical values using random numbers

7.1 Random Numbers

If you were to throw a six-sided die 100 times, each time writing down the number that shows, you would have written down ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required