Hi,
Could someone look at this and tell me where my mistake is? Thanks. Mcorn
Code:#include <iostream.h> #include <stdlib.h> int Fill_It(int, int, int, int [20]); int i; int sample[20], sample2[20], number; int t=0; int main(void) { cout << "Please enter a seed number: " ; cin >> t; Fill_It(t, 1000, 2000, sample); cout << "Twenty random numbers from 1000 to 2000\n\n"; cout << "Seed: " << t << endl; for(i = 0; i < 20; i++) cout << sample[i] << endl; cout << "Please enter another seed number: " ; cin >> t; Fill_It(t, 0, 1000, sample2); cout << "Twenty random numbers from 0 to 1000\n\n"; cout << "Seed: " << t << endl; for(i = 0; i < 20; i++) cout << sample2[i] << endl; return 0; } Fill_It(int seed, int low, int high, int test[20]){ srand(seed); i = 0; while(i <= 20){ number = rand() % high; if((number >= low) && (number <= high)){ test[i] = number; i++; } else ; } return 0; }



LinkBack URL
About LinkBacks


