1 / 10

Introduction to Computers and Programming

Join Professor Avi Rosenfeld's class for a midterm review session covering topics like rolling dice, histograms, and Craps game plan using C++ programming. Learn about functions, distributions, and enhance your programming skills. No recursion or static data types included.

carlr
Download Presentation

Introduction to Computers and Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computers and Programming Class 19 Review for Midterm #2 Professor Avi Rosenfeld

  2. Admin To do List • Introduce HW #5 • No Recursion or static data types • Questions about the exam?

  3. Phone phun http://www.cs.nyu.edu/courses/fall01/V22.0002-001/programs/class19/cpp1.c

  4. Game Plan – Rolling the “dice” • Roll one die. • Roll two dice. • Find Doubles. • Histograms of rolls. • Craps (7, 11) (2,3) or same

  5. Rolling One Die #include <time.h> #include <stdlib.h> int Roll1 () { return 1 + rand() % 6; }

  6. Rolling Two Dice int Roll2 () { return Roll1() + Roll1(); }

  7. Histogram Function (stars) void Hist(int x) { printf("The Histograph of %d is:n", x); for (int i = 0; i < x; i++) printf("*"); printf("\n"); }

  8. Using the functionsDistribution of one Die http://www.cs.nyu.edu/courses/fall01/V22.0002-001/programs/class19/cpp2.c

  9. Using the functionsDistribution of two Dice http://www.cs.nyu.edu/courses/fall01/V22.0002-001/programs/class19/cpp3.c

  10. Craps http://www.cs.nyu.edu/courses/fall01/V22.0002-001/programs/class19/craps.c

More Related