Ask Question
27 December, 19:48

Suppose that I have the following function declaration:

struct x_struct my_function (struct x_struct val);

While this is legal, it suffers from an inefficiency. What is the problem?

a.

I have no idea. This is not the answer ...

b.

The function will execute slowly because "val", and the return value of the function will both require a lot of data copying. This is because C is call-by-value.

c.

The function can not alter the original value of "val", so passing it is not useful.

d.

The function can alter the original structure "val", making the code hard to follow.

e.

The function will execute slowly because "val", and the return value of the function will both require a lot of data copying. This is because C is call-by-reference.

+4
Answers (1)
  1. 27 December, 22:21
    0
    b. The function will execute slowly because "val", and the return value of the function will both require a lot of data copying. This is because C is call-by-value.

    Explanation:

    Given Function signature: struct x_struct my_function (struct x_struct val);

    The function my_function takes a structure of type struct x_struct as arguments and returns a structure of the same type.

    C make use of call by value. So it will involve a copy of the struct argument and the return value as part of function execution. This will slow down the speed of execution particularly if the size of the structure is large. So option b is the correct option.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Suppose that I have the following function declaration: struct x_struct my_function (struct x_struct val); While this is legal, it suffers ...” 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