Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete the following programming with clear explanations. Thanks! Programming with C Primitive Types, Searching, Recursion. While there could be diverse ideas to solve b

Please complete the following programming with clear explanations. Thanks!

Programming with C

Primitive Types, Searching, Recursion.

While there could be diverse ideas to solve b and c, it is mandatory to use pointers, since the goal is for you to practice them. a) Create a file homework_part_1.c b) Create a function initialize_array that receives two parameters: an array of integers and the array size. (Use pointers to pass an array of integers as parameter) Use a for loop and an if statement to put 5s in the odd positions of the array and 0s in the even positions. Hint: review pointers as parameters. c) Create a function print_array that receives as parameters an array of integers and the array size. (Use pointers to pass an array of integers as parameter) Use a for statements to print all the elements in the array. Hint: review pointers as parameters. d) Create a function selection_sort that receives as parameters an array of integers and the array size, and order the array element in descending order. (Use pointers to pass an array of integers as parameter) Implement Selection Sort algorithm. It should be Selection Sort, not Bubble Sort, not Quick Sort, etc. e) Create a recursive function that calculate and returns the factorial of a number. The function receives the number (integer number) as parameter. f) Copy the following main function in your class, int main() { int a [10] = {3, 5, 6, 8, 12, 13, 16, 17, 18, 20}; int b [6]= {18, 16, 19, 3 ,14, 6}; int c [5]= {5, 2, 4, 3, 1};

// testing initialize_array

print_array(a, 10);

// print: 3, 5, 6, 8, 12, 13, 16, 17, 18, 20

selection_sort(a, 10);

print_array(a, 10);

// print: 0, 5, 0, 5, 0, 5, 0, 5, 0, 5 // testing initialize_array

print_array(b, 6);

// print: 18, 16, 19, 3 ,14, 6

selection_sort (b, 6);

print_array(b, 6);

// print: 19, 18, 16, 14, 6, 3 // testing factorial

printf("Factorail of 5 - %d ", factorial (5));

//print: 120 c[0] = factorial (c[0]);

c[1] = factorial (c[2]);

print_array(c, 5);

// print: 120, 24, 4, 3, 1 return 0; }

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

What would you do?

Answered: 1 week ago