Ask Question
26 January, 11:10

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.

+5
Answers (1)
  1. 26 January, 12:34
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers