Hello everyone,
I was just messing around in C++ and decided to make a random number generator to select lottery numbers. It looks like this:
Code:
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main(){
int const low = 1;
int const high = 53;
int A=0, B=0, C=0, D=0, E=0 , F=0;
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
A = rand() % (high - low + 1) + low;
B = rand() % (high - low + 1) + low;
C = rand() % (high - low + 1) + low;
D = rand() % (high - low + 1) + low;
E = rand() % (high - low + 1) + low;
F = rand() % (high - low + 1) + low;
cout << "Your randomly selected lottery numbers are: " << endl;
cout << A << " " << B << " " << C << " " << D << " " << E << " " << F << endl;
cin.get();
}
I intend to put some Boolean operators in it, so that I don't get any repeating numbers.
It's not perfect, I know, but I was wondering if I could have made this using an array?