please help me out of this c++ program please

This is a discussion on please help me out of this c++ program please within the C++ Programming forums, part of the General Programming Boards category; #include <iostream> #include <ctime> # include <cstdlib> int rolldice (void); int main ( void) { srand (time(0)); int array [12] ...

  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);
    }


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

Page 2 of 2 FirstFirst 12
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, 12: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, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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