This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: tells rand to start at different place in the sequence to get random number each time, need to change srand every timemost people use timethis function returns number of seconds since Jan 1, 1970 0:00:00 GMTeach time you run it changes because the seconds have changed Every time you call rand you get a number between 0 to 32767translate to coins even is heads odds is tailsmodulo (%) o gives you remainder after division o 4%2 = 0 o 5%2 = 1 o 10%2=0 o 15490%2=0 o 0= even o 1=odd Simpler way Generate a random # between 0 and 10 (11 numbers) modulo 11 Generate 2 to 9 (8 numbers) Mod by 8 0 1 2 3 4 5 6 7 mod by 8 plus 2 2 3 4 5 6 7 8 9 mod between 1 and 6 Final Project: Game, done in lab week after we get back Learn Pointer, no quizzes on it or after this one...
View
Full
Document
 Spring '08
 Staff

Click to edit the document details