Hey I am writing a program that will mimike a dice roll. I have the dice based on the value of a random number. the only problem is the random numbers don't change from one run to another, here is the code.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int random_integer = rand(); 
    cout << random_integer << endl; 
    cout << RAND_MAX << endl;
    int x = 6;
    int base = RAND_MAX / x;
    int firstDice;
    if( random_integer <= base)
    {
        firstDice = 1;
    }
    else if(random_integer <= base * 2)
    {
         firstDice = 2;
    }
    else if(random_integer <= base * 3)
    {
         firstDice = 3;
    }
    else if(random_integer <= base * 4)
    {
         firstDice = 4;
    }
    else if(random_integer <= base * 5)
    {
         firstDice = 5;
     }
    else if(random_integer <= base * 6)
    {
         firstDice = 6;
         }
    int random2 = rand();
    int secoundDice;
    if( random_integer <= base)
    {
        secoundDice = 1;
    }
    else if(random2 <= base * 2)
    {
         secoundDice = 2;
    }
    else if(random2 <= base * 3)
    {
         secoundDice = 3;
    }
    else if(random2 <= base * 4)
    {
        secoundDice = 4;
    }
    else if(random2 <= base * 5)
    {
         secoundDice = 5;
     }
    else if(random2 <= base * 6)
    {
         secoundDice = 6;
         }
    int random3 = rand();
    int thirdDice;
    if( random3 <= base)
    {
        thirdDice = 1;
    }
    else if(random3 <= base * 2)
    {
         thirdDice = 2;
    }
    else if(random3 <= base * 3)
    {
         thirdDice = 3;
    }
    else if(random3 <= base * 4)
    {
        thirdDice = 4;
    }
    else if(random3 <= base * 5)
    {
         thirdDice = 5;
     }
    else if(random3 <= base * 6)
    {
         thirdDice = 6;
         }
    cout << firstDice << secoundDice << thirdDice << endl;
    system("PAUSE");
    return EXIT_SUCCESS;

Please help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.