rolling of two dice


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: rolling of two dice

  1. #1
    Join Date
    Apr 2005
    Posts
    2

    Question rolling of two dice

    write a program that simulates the rolling of two dice. the program should use rand to run the first die and sjould use rand again to roll the second die. the sum of two values should then be calculated. your programe should roll the dice 36000 times. use a single subscripted array to tally the number of times each possible sum appears. print the results in a tabular format. also determine if the totals are reasonable.

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    Hint: rand()%6 +1 is a value from 1..6, assuming you have 6-sided dice, which it does not say (common dice: 4,6,8,10,12,20,30,100). The results won't always be what you expect because most c++ compilers have crappy rand functions and using % on it makes it worse.

    Code it up and ask again when you have made an attempt at it.

  3. #3
    Join Date
    Apr 2005
    Posts
    2
    thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center