Thread: C++ Asignment

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

    C++ Asignment

    could someone help me with this im trying to make a program that displays five dice rolls of two dice where each die is a number from 1 to 6, and shows the total. when run, the program should look like this:

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

    Ok i got the first part i think but when i run it, it comes up with the same output everytime. also it has to be in some kind of loop. I dont want it to be the same output every time its like the randomizer isnt working. hears what i have so far:

    /*Random Numbers
    3/25/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
    Jan 2003
    Posts
    78
    Look into srand()

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    FAQ .We take the time to make it. You should take the time to read it.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

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