Question: URGENTT C PROGRAMMING (c) Consider a function called clone that takes an array integer values as a parameter and that replaces each odd number with
URGENTT 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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
