Question: URGENNT C PROGRAMMING c) Consider a function called clone that takes an array integer values as a parameter and that replaces each odd number with

URGENNT C PROGRAMMING

c) Consider a function called clone that takes an array integer values as a parameter and that

replaces each odd number with two of that number and that removes all even values. For

example, suppose that a variable called array stores the following sequence of values:

[3, 8, 19, 42, 7, 26, 27, -8, 193, 204, 6, -4] and we make the following call:

m = clone (array, list, n);

Afterwards list should store the following sequence of values:

[3, 3, 19, 19, 7, 7, 27, 27, 193, 193]

Notice that each odd number has been duplicated (3, 19, 7, 27, 193) and that the even values have been removed (8, 42, 26, -8, 204, 6, -4). The variables n and m are the

length of array and list respectively.

The following is a proposed implementation of clone: void clone (int a[], int b[], int n)

{

int i, val;

for (i=0; i < n; i++)

{

val = a[i]; if (val%2!=0)

b[i] = val; i++;

b[j] = val;

return;

This implementation has one or more bugs. Modify the implementation so that it behaves as described above. Your modified method should retain the same basic approach to the problem as the buggy implementation; you should not write an entirely new implementation.

(d) Determine if the following function will return a value. If so, explain what it returns. If not, explain why not.

float add loop()

float fl = 1E30; // this is 1 * 10-30 in decimal float f2 = 1E-30;

while (fl > 1E29)

fl -= f2;

return fl;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!