Question: Write a program in C that copies every third element in an input array to an output array and discards all the other values. The

Write a program in C that copies every third element in an input array to an output array and discards all the other values. The program should include the following function: void decimate_by3(int a1[], int n, int a2[])T he function copies every third element in an input array a1[] of length n to an output array a2[]

and discards all the other values. (Hint: you might need the modulus (reminder) operator %)

1) read the numbers in the array, for example, 3 6 8 9.

2)Assume the input array has three or more elements.

3)In the main function, declare the input array after reading in the number of element of

the array, then read in the elements, then calculate the length of the output array, and

declare the output array, then call the decimate_by3 function.The main function should

display the output array.

Example input/output #1:

Enter

the length of the array: 8

Enter the elements of the array: 3 4 7 14 9 12 8 2

Output:3 14 8

Example input/output #2:

Enter

the length of the array: 6

Enter the elements of the array: 3 4 7 14 9 12

Output: 3 14

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!