need help guys..........

This is a discussion on need help guys.......... within the C Programming forums, part of the General Programming Boards category; Modify the program in Part 1 to keep track of the sum of rolling a pair of dice. The possible ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    need help guys..........




    Modify the program in Part 1 to keep track of the sum of rolling a pair of dice. The possible totals for each roll are 2 to 12.
    The theoretical distribution for the totals is shown in the table below. Compare your results with these.






    Total Number of combinations Probability
    2 1 2.78%
    3 2 5.56%
    4 3 8.33%
    5 4 11.11%
    6 5 13.89%
    7 6 16.67%
    8 5 13.89%
    9 4 11.11%
    10 3 8.33%
    11 2 5.56%
    12 1 2.78%


    ( Total is 2-12:-Row 1, Number of combination 1 to 1:- Row2 ,Probability 2.78% -2.78%:- Row 3)




    [
    PHP Code:
    #include <stdio.h>
    #include <time.h>

    main(){
       
    int i;
       
    int record[7];
       
    int count=0;
       
    int MAXCOUNT=2000000;

       
    srand(time(NULL));

       do{    
    //User input
          
    printf("Enter the number of trials (max %d): ",MAXCOUNT);
          
    scanf("%d",&count);
       }while(!(
    count>0&&count<=MAXCOUNT));

       
    //zero the array
       
    for(i=1;i<=6;i++){
          
    record[i]=0;
       }

       
    //roll and record the value
       
    for(i=0;i<count;i++){
          
    record[rand()%6+1]++;
       }

       
    //display Results
       
    printf("Result  Times  Percentage\n");
       
    printf("       Rolled\n");
       for(
    i=1;i<=6;i++){
          
    printf(" %2d  %8d  %5.2f%%\n",i,record[i],record[i]*1.0/count*100);
       }

    ]
    i Hope you Guys understand my question?

    Thanx...help needed

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I understand your question, but I'm not going to do your homework for you.

    You need to state what the problem is that you need help with, not "here's the assignment and what I've got so far, please code it up".

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    3
    just need idea(help) .i don't ask any one to write program for me....

  4. #4
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    Well wouln't the total number of combinations divided by two get you your total sum of rolling the dice?

    Simply keep track of how many times this is called

    Code:
       record[rand()%6+1]++;

    Since you must hit this at least twice for each roll, so by keeping track of this count then at the end divide by two will get you your total sum.

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    3
    hey thanxx buddy...i "ll will try that...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hey guys, I'm new!
    By MrDoomMaster in forum C++ Programming
    Replies: 15
    Last Post: 10-31-2003, 05:47 PM
  2. How long have you guys been working with C/C++??
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 08-01-2003, 04:41 PM
  3. Tic Tac Toe -- Can you guys rate this please?
    By Estauns in forum Game Programming
    Replies: 2
    Last Post: 09-15-2001, 11:22 AM
  4. hello guys
    By lupi in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 07:42 AM
  5. hello guys
    By lupi in forum C++ Programming
    Replies: 1
    Last Post: 09-09-2001, 02:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21