C program using a user-defined function and random number generation, edited