Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

f) Copy the following main function in your class, int main() { int a [10] = {3, 5, 6, 8, 12, 13, 16, 17, 18,

image text in transcribed

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 initialize_array(a, 10); print_array(a, 10); // print: 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 // testing initialize_array print_array(b, 6); // print: 18, 16, 19, 3 ,14, 6 selection_sort (b, 6); print_array(b, 6); // print: 3, 6, 14, 16, 18, 19 // 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; }

3. Part 1. Primitive Types, Searching, Recursion (35 points). 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 a for loop and an if statement to put 0s in the odd positions of the array and 1s 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 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 ascending order. Implement Selection Sort algorithm. It should be Selection Sort, not Bubble Sort, not Quick Sort, etc. If you do not remember selection sort, this link could be useful: https://goo.gl/hrAdMo e) Create a recursive function that calculate and returns the factorial of a number. The function receives the number (integer number) as parameter Copy the following main function in your class, int main) f) 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, 11: // testing initialize_array print array(a, 10)/ print: 3, 5, 6, 8, 12, 13, 16, 17, 18, 20 initialize array (a, 10) print array(a, 10) // print: 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 // testing initialize array print array (b, 6) / print: 18, 16, 19, 3 ,14, 6 selection_sort (b, 6); print_array(b, 6) print: 3, 6, 14, 16, 18, 19 // testing factorial printf("Factorail of 5 d ", factorial (5) //print: 120 (O) factorial (c(o)) factorial (c(2)) print array(c, 5): // print: 120, 24, 4, 3. 1 return 0 iteria for the pa 01 pts: file contains header information 01 pts: adequate comment to explain every function 01 pts: consistent indentation and spacing 08 pts: selectionSort 08 pts: printArray 08 pts: initializeArray 08 pts: factorial

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_2

Step: 3

blur-text-image_3

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

Explain the various employee benefit laws.

Answered: 1 week ago

Question

=+When and under what circumstances are contracts renegotiated?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago