Hi,
I am trying to generate 2000 random 3 bit binary numbers. I am using the following code to do that but I am getting an error.
#include <bitset>
#include <stdio.h>
#include <cstdlib>
#include <strings.h>
#include <iostream>
#include <vector>
#include <time.h>
using namespace std;
int main()
{
for(int i=0; i<2000; i++)
{
cout<< bitset<3> (unsigned char ( (rand() ) ) <<"\n";
}
return 0;
}
Can someone tell me the right way to generate random binary numbers like
000
001
010
..
Thanks