Write a function called nRandomNumbers( ) to performing the following:

• Generates N random integers between -250 and 250 (inclusive) and save them in a file called number.txt, (Use the function srand()).

• Prints all the generated integers.

• Finds the average of all the negative integers, and the maximum of all the positive integers.

• Returns the the average and maximum values.

Write a main program that perform the following:

• Prompts the user to input the value of N.

• Calls the function nRandomNumbers( ).

• Prints the average of all the negative integers, and the maximum of all the positive integers.

i really need help in writing this program,ive tried everything n it still doesnt work..this is what i have so far...

```
#include<iostream>
#include<iomanip>
#include<ctime>
using namespace std;
void nRandomNumbers(int x,int&y,int&h);
int main()
{
int N,maxP,aveN;
int a = -250;
int b = 250;
cout << "Enter the value of N: ";
cin >> N;
int nRandomNumbers(N);
cout << "the 5 random integers are:"<<N<<endl;
cout << "the average of all negative integers is" <<aveN <<endl;
cout << "the maximum of all positive integers is" << maxP << endl;
return 0;
}
void nRandomNumbers(int x,int&y,int&h)
{
int N,b,a=0,aveN,maxP;
int neg=0, zero=0, pos=0;
srand((unsigned)time(0));
for(a=N;a<=501;a++)
{
N = a + rand() % (a-b) + 1;
if( N<0 )
{
aveN+=1;
neg++;}
else if( N>0 )
{
maxP=(aveN/a++);
pos++;
}
}
```

and what does 'unexpected end of file'mean i keep getting this error?

*Edited 6 Years Ago by WaltP*: Added CODE Tags