Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am lost in what I should put for Void arrCopy(), can someone explain, please? Given code for arrCopy.c #include #include int size; // Variable

I am lost in what I should put for Void arrCopy(), can someone explain, please?

image text in transcribed

image text in transcribedGiven code for arrCopy.c

#include

#include

int size; // Variable to record size of original array arr

int evenCount = 0, oddCount = 0; // Variables to record sizes of new arrays arr_even and arr_odd

int *arr; // Dynamically allocated original array with #elements = size

int *arr_even; // Dynamically allocated array with #elements = #even elements in arr (evenCount)

int *arr_odd; // Dynamically allocated array with #elements = #odd elements in arr (oddCount)

char *str1 = "Original array's contents: ";

char *str2 = "Contents of new array containing even elements from original: ";

char *str3 = "Contents of new array containing odd elements from original: ";

// DO NOT change the definition of the printArr function when it comes to

// adding/removing/modifying the function parameters, or changing its return

// type.

void printArr(int *a, int size, char *prompt){

// Your code here

}

// DO NOT change the definition of the arrCopy function when it comes to

// adding/removing/modifying the function parameters, or changing its return

// type.

void arrCopy(){

// Your code here

}

int main(){

int i;

printf("Enter the size of array you wish to create: ");

scanf("%d", &size);

// Dynamically allocate memory for arr (of appropriate size)

// Your code here

// Ask user to input content of arr and compute evenCount and oddCount

// Your code here

// Dynamically allocate memory for arr_even and arr_odd (of appropriate size)

// Your code here

/*************** YOU MUST NOT MAKE CHANGES BEYOND THIS LINE! ***********/

// Print original array

printArr(arr, size, str1);

/// Copy even elements of arr into arr_even and odd elements into arr_odd

arrCopy();

// Print new array containing even elements from arr

printArr(arr_even, evenCount, str2);

// Print new array containing odd elements from arr

printArr(arr_odd, oddCount, str3);

printf(" ");

return 0;

}

ndividual Assignment 3: Complete arrCopy . c Study and complete arrCopy. c so that it outputs the following sample result in the same format. You must only insert code in the segments labelled with //Your code here. Contents of all arrays must be accessed through pointers, so you must not use any array notation ([]) in your code. Hint: Use dynamic memory allocations (malloc)! Your program must produce an output that exactly resembles the Sample Run, including identical wording of prompts, spacing, input locations, etc. Sample Run (user input shown in blue, with each run separated by a dashed line): Enter the size of array you wish to create: 5 Enter array element \#1: 1 Enter array element \#2: 2 Enter array element \#3: 3 Enter array element \#4: 4 Enter array element \#5: 5 Original array's contents: 12345 Contents of new array containing even elements from original: 24 Contents of new array containing odd elements from original: 135 Enter the size of array you wish to create: 0 Original array's contents: empty Contents of new array containing even elements from original: empty Contents of new array containing odd elements from original: empty Enter the size of array you wish to create: 4 Enter array element \#1: 1 Enter array element \#2: 3 Enter array element \#3: 5 Enter array element \#4: 7 Original array's contents: 1357 Contents of new array containing even elements from original: empty Contents of new array containing odd elements from original: 1357

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions