how to use srand function

Write a function called nRandomNumbers( ) to perform the following tasks:

1. Generate N random integers between -250 and 250 (inclusive) and save them in a file called number.txt, (Use the function srand()).
2. Print all the generated integers.
3. Compute and return the average of all the negative integers, and the maximum of all the positive integers
I dont know how to use srand function please help me;
I wrote the code but its gives me error