Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include using namespace std; void RandomNumbers(int*); void ReadFile(int*); void PrintValue(const int* [], int); int main() { int number; RandomNumbers(&number); ReadFile(&number); system(Pause); return

image text in transcribedimage text in transcribed

#include

#include

#include

#include

using namespace std;

void RandomNumbers(int*);

void ReadFile(int*);

void PrintValue(const int* [], int);

int main()

{

int number;

RandomNumbers(&number);

ReadFile(&number);

system("Pause");

return 0;

}

void RandomNumbers(int* RandomNumbers)

{

ofstream banana;

int RNG;

banana.open("beta.txt");

srand(time(0));

for (int x = 0; x

{

RNG = rand() % (200 - 1) + 1;

banana

}

banana.close();

}

void ReadFile(int* ReadFile)

{

ifstream banana;

int orange;

int count = 0;

int* fruits = nullptr;

banana.open("beta.txt");

while (!banana.eof()) {

banana >> orange;

count++;

}

banana.close();

fruits = new int[count];

PrintValue(fruits[] , count);

}

void PrintValue(const int* banana[] , int size)

{

for (int i = 0; i

{

cout

}

}

This is the code that i currently have and i want to know how to make part C and D work.

Document1 Wrd File Insert Design Lxext References Mailings Review VirHrp Tell me what you want to do Home Cut Copy Format Painter IU- Sharee Find Replace Faste Blu-ab x,x'A-3?,A- =?,A-EL, 1Norma. No Spac Heading 1 Heading 2 Title Subtitle Subte Em Emphassitense E Strong Quote ?b Select Paragrap Ecting This HW is a practice on using pointers. Use pointer notation instead of common subscript array notation (i.e. *(xti) instead x]) Your program should A- At startup: generate integer random numbers and place them in a file. Each number on a single line The numbers should range between 1-200 and the program should generate between 100-150 numbers. This means each time the program is executed, a file is created containing between 100-150 numbers with values between 1-200. Make sure you close the file once the numbers are generated. This should be done in a separate function B- The program should then read the file and create a dynamic array that holds the numbers. The size of the array is the number of elements in the file just read. This should be in a separate function C- Print values of the array: this should be done by creating a function that accepts two arguments, a const integer pointer to the array and size printValues const int "arr, int size) D- The program should ask the user to enter a "key value" and then find all numbers that are above that key value, store them in a dynamic array and return that array. Then your program should call the printValues function passing the new array. This should be implemented in as a pointer returning from a function (i.e. the function should return a pointer to the new array) 4- Print the array in reverse. Your program (via a function) should create a new copy of the array, except that the elements should be in reverse. The function should return a pointer to the new array. Then call printValues to show the values of the new array Make sure you do not forget to deallocate memory after use Pae 1 uf1 2 words +137 O Type here to search 1:03 I'M 45/2018

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

Students also viewed these Databases questions

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago