Lecture 15: May 28, 2024

Reading: zyBooks text, §2.10, 2.19, 3.13, 3.14, 8.5, 10.8
Assignments: Homework 3, due May 29 (Note extension); Extra Credit 2, due May 29 (Note extension)

  1. Random and pseudorandom number generation
    1. Pseudorandom numbers vs. random numbers
    2. Pseudorandom number generators rand, random [prand1.c, prand2.c]
    3. Seeding a pseudorandom number generator [prand1.c]
    4. Obtaining random numbers [rand.c]

  2. String functions [strings.c]

  3. Copy, compare sequential bytes in memory [mem.c]

  4. Math functions [mhodge.c]

  5. Buffer overflow on the stack [bad2.c]

  6. Writing a program with random numbers
    1. Monty Hall problem [monty1.c]
    2. Basic program, human does all selection of doors [monty2.c]
    3. Fix bug and simplify calculation of win/lose [monty3.c]
    4. Add randomness [monty4.c]
    5. Delete Monty showing user a door [monty5.c]
    6. Change main to determine whether switching wins or loses [monty6.c]
    7. Clean up, and add clearer output at the end [monty7.c]
    8. Make the number of rounds a macro [monty8.c]
    9. Let user specify number of games on the command line [monty9.c]

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 36A, Programming & Problem Solving
Version of May 29, 2024 at 5:07PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh