Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program even_odd.c that include the following function. void is_even(int

ID: 3899302 • Letter: W

Question

Write a program even_odd.c that include the following function.

void is_even(int numbers[], int n, int result[]);

The is_even function determines if an element in the array is an even number.If it is even, the function stores 1 in the result array at the same index, otherwise, it stores 0.

In the main function, ask the user to enter the number of integers(length of the array),and then enter the array elements. You will need declare the arrays with the length, and call the function. The main function should display the result.The functionality of this program will be based on if the function is implemented as required.

Sample run:

Enter the number of integers: 5

Enter the array elements: 32 24 7 21 19

Output:

The output array: 1 1 0 0 0

Explanation / Answer

Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you


#include <stdio.h>
void is_even(int numbers[], int n, int result[]);

int main()
{
int numbers[20]; //stores upto 20 numbers
int n;
int result[20];
int i;

printf("Enter the number of integers: ");
scanf("%d", &n);

printf("Enter the array elements: ");
for(i = 0; i < n; i++)
scanf("%d", &numbers[i]);

is_even(numbers, n, result);

printf("The output array: ");
for(i = 0; i < n; i++)
printf("%d ", result[i]);

printf(" ");

}
void is_even(int numbers[], int n, int result[])
{
int i;
for(i = 0; i < n; i++)
{
if(numbers[i] % 2 == 0) //is it even?
result[i] = 1;
else
result[i] = 0;
}
}


output
====
Enter the number of integers: 5
Enter the array elements: 32 24 7 21 19
The output array: 1 1 0 0 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote