i was working on a simple idea of generating random numbers (from 1 to 100) and printing them on the console using c++ but the problem is that each time i run the program it geberates exactly the same numbers each time, it's random, a single number isn't repeated but the same order of random numbers every time!
here's my code
// DigitDisplayer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int max = 100;
int min = 1;
int range = (max - min) + 1;
int randnum;
bool nums[100];
for(int j = 0; j < sizeof(nums); j++)
{
nums[j] = false;
}
for(int i = 0; i < range; i++)
{
int randnum = (rand() % range) + 1;
if(nums[randnum] == false){
nums[randnum] = true;
cout<< randnum << "\n\n";
}
else {
int randnum = (rand() % range) + 1;
}
}
cout<< "DONE!!!\n\n";
system ("pause");
}
Thanks