Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write in c programming In this task a parity array type should be implemented. This is an array of integers where even numbers go to

write in c programming

image text in transcribed

image text in transcribed

In this task a parity array type should be implemented. This is an array of integers where even numbers go to the beginning and the odd numbers go to the end of the array. For example such a 5 element array is initially empty: After adding 2: 2 After adding 7: 27 After adding 1: 2 . - 17 After adding 9: 2 _ 917 After adding 4: 24916 Base task (10 points) Create a struct named . This contains a fixed-size array. The size should be given by a preprocessor macro token named . Its value should be 10. Furthermore, the structure contains two integers: and . These indicate the positions where the next even and odd number is inserted in the array. Create a function which is given a as parameter and initializes it. It sets the value of to 0 and to Create a function which is given a and an integer parameter. This function inserts the integer in the array to its correct position and sets the indexes accordingly. Create a function which is given a and prints its values. Make sure to print only the inserted elements. Empty elements shouldn't be printed. Heap usage (10 points) Modify the struct so it contains a pointer instead of the array. This pointer will point to an array which is allocated in the heap memory. The size of this array should be given as parameter to function. Modify function so it allocates the array in the heap memory. The macro doesn't need to be used anymore, but don't remove it from your source code. Create a function which is given a as parameter and deallocates the underlying array. Modularization (5 points) Separate your program to multiple translation units. The , and function definitions should be replaced to a different source file. Create the corresponding header file which contains the struct and the function declarations. Don't forget the headerguard idiom. I/O handling (5 points) Read a number from the keyboard. Create a and initialize it with this size. Then read this many integers from the user and insert those numbers to the Create a function which writes the array elements to a text file

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

Students also viewed these Databases questions

Question

Explain in detail how the Mughal Empire was established in India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I - -[ze dx

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = 1- 1 dx 9

Answered: 1 week ago

Question

Design a job advertisement.

Answered: 1 week ago