Ask Question
23 January, 07:01

Write a function called calculate () that accepts three integer Numbers as arguments, compute these values : Sum and Product and Return these computed results to the main program.

+1
Answers (1)
  1. 23 January, 09:51
    0
    int * calculate (int a, int b, int c) {

    int result[] = {0,0};

    int sum = a+b+c;

    int product = a*b*c;

    result[0] = sum;

    result[1] = product;

    return result;

    }

    Explanation:

    The function is a block of the statement which performs the special task.

    The function can return one integer, not more than one integer.

    If we want to return multiple values then, we can use array.

    we store the result in the array and return that array to the main function.

    This is the only possible way to return multiple values.

    So, define the function with return type array and declare the array with zero value.

    Then, calculate the values and store in the variable after that, assign to the array.

    Finally, return that array.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a function called calculate () that accepts three integer Numbers as arguments, compute these values : Sum and Product and Return ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers