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

In C++ Develop a program that creates a dynamic array of function pointers that

ID: 3881802 • Letter: I

Question

In C++

Develop a program that creates a dynamic array of function pointers that return void and takes an integer parameter. It will then initialize the array with values as addresses of f1, f2, f3 in sequence. It will also, produce a call sequence array and shuffle it 100 time and then pass these two arrays to a function that will call the functions in the first array according to the sequence in the second array, which terminates with an -1 terminator.

evelop a proc rann hat ea a dynamic arra a un lun poln ers tat return vold and akes an inter er parameter wi then ini ialzt: the array with valuns as addresses a pass these two arrays to a function that will cal the functions in the first array according to the sequence in the second array, which terminates with an-1 terminator £2 B n sequence It will also produce a ca sequence array and shuff !! it tirne and her!

Explanation / Answer

Solution:

code:

#include <iostream>
#include <cstdlib>// library for srnd
using namespace std;
int main()
{
int ***array; //Declaring pointer
char character;

array = new int**[5];//memory is dynamically allocated here.
for(int m=0;m<5;m++)
{
array[m]=new int*[5];
for(int n=0;n<5;n++)
{
array[m][n]=new int[5];
  
}
}
do
{
//Initilizing range 1 to 9 numbers to array
for(int m=0;m<5;m++)
{
for(int n=0;n<5;n++)
{
for(int o=0; o<5; o++)
{
array[m][n][o]=rand() % 9 + 1;
}
}
}
//Displaying array
for(int m=0; m<5; m++)
{
for(int n=0; n<5; n++)
{
for(int o=0; o<5; o++)
{
cout<<array[m][n][o]<<" ";
}
cout<<endl;
}
cout<<endl;
}
cout<<" Continue? (Y/N) : ";
cin>>character;
}while(character!='n'&&character!='N');
return 0;
}

Output:

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)