mercredi 23 septembre 2015

How do I store a random number in C++

So far, I have made a program that creates a random number using srand and rand.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{

    srand(time(0));

    for(int x = 1; x<25;x++) {
        cout << 1+ (rand()%6);
    }

}

How do I store the random number using int?




Aucun commentaire:

Enregistrer un commentaire