Question

vDeclare a 12-element array of pointers to functions. Each function will accept two double-precision quantities as...

vDeclare a 12-element array of pointers to functions. Each function will accept two double-precision quantities as arguments and will return a pointer to a double-precision quantity.

c++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

v)Answer:-

Screen shot of program:-

Sample output:-

Copy program:-

#include <iostream>

using namespace std;

double *fn1(double n1, double n2) {
double *result = new double;
*result = 1;
return result;
}

double *fn2(double n1, double n2) {
double *result = new double;
*result = 2;
return result;
}

int main() {
double *(*fnPointers[12])(double, double);

fnPointers[0] = fn1;
fnPointers[1] = fn2;

cout << *fnPointers[0](0, 1) << endl;
cout << *fnPointers[1](0, 1) << endl;
return 0;
}

Add a comment
Know the answer?
Add Answer to:
vDeclare a 12-element array of pointers to functions. Each function will accept two double-precision quantities as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments:...

    c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. The function should open the specified file in binary mode, write the contents of the array to the file, and then close the file. Write another function named fileToArray. This function should accept three argu- ments: the name of a file, a pointer to an int array, and the size...

  • average Function Write a function that finds an average of the array using only pointers (and...

    average Function Write a function that finds an average of the array using only pointers (and pointer arithmetic) to move through the array. Test the function in a driver program. Function header: double average(int* array, int size)

  • C++ Programme Write a function that receives, as arguments, a pointer to a double array, as...

    C++ Programme Write a function that receives, as arguments, a pointer to a double array, as well as the number of elements: in the array(int). The function must use pointer operations and calculate the standard deviation of the elements in the array. The function returns the standard deviation to the calling statementſ Use the function in main( to display its operation. | Example: array = (11.2, 2.4, 3.13, 16.4, 5.8, 9.22, 4.9, 10.5, 6.5, 2.99) std Dev(array) = 4.249367 ZWI...

  • Write a function that will accept an array of string. Return the index of the element...

    Write a function that will accept an array of string. Return the index of the element that has the most vowels. For this exercise, vowels are a,e,i,o, and u. If none of the strings contain a vowel, return -1. If two or more words contain the same largest amount of vowels, either index of such words is acceptable. (using C++)

  • Write templates for the two functions minimum and maximum. The minimum function should accept two arguments...

    Write templates for the two functions minimum and maximum. The minimum function should accept two arguments and return the value of the argument that is the lesser of the two. The maximum function should accept two arguments and return the value of the argument that is the greater of the two. Test your functions in a main program that propmts the user to choose what type of data they would like to compare (ints, doubles, or strings). Then, it should...

  • Write in C code: Define an array f=[23,-12,34,-56,-10,12,19], using call-by-reference (use pointers), to pass the array...

    Write in C code: Define an array f=[23,-12,34,-56,-10,12,19], using call-by-reference (use pointers), to pass the array to a function, named Summation. In main: Define array, pass array, print out the array and the result returned from Summation on screen. In function Summation: 1)take array and size from main 2) sum each element according to the following rules 3) if the value of f(i) is positive, add 2*f(i) to the sum 4)if the value of f(i) is negative, add -3*f(i) to...

  • - Write a program that performs several operations on an array of positive ints. The program...

    - Write a program that performs several operations on an array of positive ints. The program should prompt the user for the size of the array (validate the size) and dynamically allocate it. Allow the user to enter the values, do not accept negative values in the array. - Your program should then define the functions described below, call them in order, and display the results of each operation: a) reverse: This function accepts a pointer to an int array...

  • (Find the smallest element) use pointers to write a function that finds the smallest element in...

    (Find the smallest element) use pointers to write a function that finds the smallest element in an array of integers. Use {1,2,4,5,10,100,2,-22} to test the function. using the following header. int minindex(double* list, int size) example output: array size: 8 number 1: 1 number 2: 2 number 3: 4 number 4: 5 number 5: 10 number 6: 100 number 7: 2 number 8: -22 smallest element is: -22 C++ only.

  • Can someone help me understand this step by step (C++) Array Shifter and Array Reversal Write...

    Can someone help me understand this step by step (C++) Array Shifter and Array Reversal Write a function that accepts an array of doubles and the array's size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to element 1 of the new array, element 1 of the argument array...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT