Thread: please help me out of this c++ program please

  1. #16
    Registered User
    Join Date
    Apr 2003
    Posts
    6

    i got some thing like this and couldnt move a head

    #include <iostream>

    #include <ctime>

    # include <cstdlib>

    int rolldice (void);

    int main ( void)
    {
    srand (time(0));
    int array [12] = { 1,2,3,4,5,6,7,8,9,10,11,12};
    int counter = 0;

    for (int i= 0; i<=36000; i++)
    ++counter [ 1+rand()%6];
    {
    sum = rolldice();

    switch (sum)

    {
    int die1;
    int die2;
    int sum;
    die1 = ( 1+ rand ()% 6);

    die2 = ( 1+ rand ()% 6);
    sum = die1+die2;
    return sum;
    }
    }
    }

  2. #17
    Registered User
    Join Date
    Apr 2003
    Posts
    6

    Please tell me now what to do???

    #include <iostream.h>
    #include <ctime.h>
    #include <stdlib.h>

    int rolldice ();

    int main ()
    {

    int array [13] = { 0 }; // Set all 13 counters to 0

    srand (time (0));
    for (int i=0; i<=36000; i++)
    {

    array [rolldice ()]++;
    }


    for (int iSum=2; iSum<13; iSum++) {
    cout << "Sum of " << iSum << " appeared " << array [iSum] << " times." << endl;
    }

    return 0;
    } // end 'main()'

    int rolldice ()
    {
    return (1 + rand ()%6) + (1 + rand ()%6);
    }


    --------------------------------------------------------------------------------

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM