Thread: C++ Asignment

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    2

    C++ Asignment

    Im having trouble with a C++ assignment. I need to write a program like this: Write a program that displays fice rolls of two dice where each die is a number from 1 to 6, and shows the total. when run the programs output should look somewhat like this:

    2 4= 6
    1 1= 2
    6 6= 12
    4 3= 7
    5 2= 7

    ok i got the program to display the output but it dosent randomize differently every time i run it. It has to be in somesort of a loop. Heres what i got so far:

    /*dice
    2/18/03 */

    #include <iostream.h>
    #include <math.h> //Randomizer

    int main()

    {
    int die
    for (int roll= 1; roll<= 5; roll++)
    double die=1+random(6)
    cout<<die<<endl;

    return(0);
    }

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    with the above code, the cout doesn't know which die to output.

    edit: best not to make two threads. and like mentioned, read the FAQ.
    Last edited by alpha; 03-25-2003 at 10:13 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Asignment
    By General912 in forum C++ Programming
    Replies: 2
    Last Post: 03-25-2003, 09:26 PM