First off you are %ing by the wrong number rand()%y will generate a random number between 0 and y-1. Second your loop is only filling in 39 of the 40 values you have allocated to your arrays. Third (0 rand() % 9) will give you an error because there is no operator between 0 and rand(). Fourth although its not necessary, you should seed the random number generator with srand(uint) where the seed given is normally time(NULL) to pass the current time so that each run of the program generates new numbers based off of the current time. This last part would require you to include time.h also.