Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

ID: 664261 • Letter: W

Question

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 srand0). . 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.V Calls the function nRandomNumbers(). Prints the average of all the negative integers, and the maximum of all the positive integers.

Explanation / Answer

#include<iostream>
#include<iomanip>
#include<ctime>
using namespace std;
int nRandomNumbers(int&x);
int avgN(int&y);
int max(int&z);
int main()
{
int N,maxP;
int a = -250;
int b = 250;

cout << "Enter the value of N: ";
cin >> N;
int nRandomNumbers(N);
cout << "the random integers are:"<<N<<endl;
cout << "the average of all negative integers is" <<avgN <<endl;
cout << "the maximum of all positive integers is" << maxP << endl;
return 0;
}

int nRandomNumbers(int x,int&y,int&z)
{
int N,b,a=0,avgN,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 )
{
avgN+=1;
neg++;
}
else if( N>0 )
{
max=(avgN/a++);
pos++;
}
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote