Write a program that implements the following pseudo code: Declare and initializ
ID: 3536857 • Letter: W
Question
Write a program that implements the following pseudo code:
Declare and initialize arrays/variables
Display menu
1. create a dynamic array of random elements (array size indicated by the user) and
write it into a file indicated by the user
2. load a dynamic array of elements from a file indicated by the user
3. sort the array
4. display the array
5. exit
If menu choice 1
Call a function to populate the array:
Ask the user for the number of elements (size of the array)
Ask the user for a seed (a seed is any positive integer)
Generate a dynamic array of random numbers from the set
{5, 10, 15, 20, %u2026, 95, 100}
Ask the user for file name
Call a function to write the content of the array into the specified file
Display a prompt for successful operation
Else if menu choice 2
Ask the user for the file name
Call a function to load the content of the file into a dynamic array of elements
Display a prompt for successful operation
Else if menu choice 3
Call a selection sort function to sort the current array
Else if menu choice 4
Call a function to display the content of the current array on a single line with elements separated by | (Important: no | after the last element)
Else if menu choice 5
Display an exit message
Else
Display an error on input prompt
If not an exit condition
Display the menu again
I only need help with number 1. Please help :)
Explanation / Answer
please rate - thanks I change the %u2026 to it's hex value, hope that's correct this is only the code for part 1, --I showed how it would fit in the program message me if any changes needed #include #include #include using namespace std; void populate(); int menu(); void writeFile(ofstream& ,int[],int); int main() {int m=menu(); if(m==1) populate(); else return 0; } int menu() {return 1; } void populate() {int values[]={5, 10, 15, 20,8230, 95, 100}; int elements,seed,i; int *array; char filename[30]; ofstream out; coutelements; coutseed; srand(seed); array=new int[elements]; for(i=0;i>filename; out.open(filename); writeFile(out,array,elements); coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.