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?

you have 10 minutes in which you can edit your code, and make it look right.

After that, you can't.

Click on the "edit" button, then click on "go advanced" button.

Now highlight your code with the mouse, and click on the [code] icon at the top of the advanced editing window.

That will help make your code look much better.

Do that now, and I'll post back, afterward.

Your error means that you have more { braces, than you have } braces.

If you indent your code just 2 to 5 spaces (not tabs), and use code tags, then errors like this are super easy to spot - for you and everyone else.

If you don't do it, people tend to ignore your posts more often.

Learn to format your code properly and the error will be readily apparent.

After that, if you need more help, you need to tell us what's wrong. We didn't write the code, you did. Explain.

commented: Exactly :) +8

Also, not to be fussy (but I will be anyway) isn't this C++ code?

i dont know the exact order of the code,n i dont know the equation for finding the average n the maximum of all positive integers

if( number > 0) then add it into the variable representing the sum of the positive integers.

Average of the group = sum of the group, divided by the number in the group.

Note that "Text speak" is not too welcome, here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.