I am having trouble telling the computer to select 3 random numbers and write them out.
There should be three number and each should be different, but some how they all come out the same number!Code:#include <stdio.h> #include <time.h> #include <stdlib.h> #include <iostream.h> #include <windows.h> int Chance1 , Chance2 , Chance3; void main(void) { cout << "These 3 numbers should be different: \n"; { srand( (unsigned) time (NULL) ); Chance1 = rand() % 10; cout << Chance1 << "\n"; srand( (unsigned) time (NULL) ); Chance2 = rand() % 10; cout << Chance2 << "\n"; srand( (unsigned) time (NULL) ); Chance3 = rand() % 10; cout << Chance3 << "\n"; } }
Any help would be most appreciated,
Paul