Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a program that will receive 10 random (non-sorted) integer numbers from the user into an array, then the program will print out the

1. Write a program that will receive 10 random (non-sorted) integer numbers from the user into an array, then the program will print out the 10 elements of the array. Capture/copy one test screen output and place it at the end of the C file as multiline comments within /* */. Save it as Lab5A.C. 2. Modify the Lab5A.C program as follows (save it as Lab5B.C): Create one single function called ascending() to sort the elements of an array from from smallest to largest. The ascending() function takes parameters, the first one is the address of an array, the second one is the size of the array. The function must have a prototype similar to this void ascending(int numbers[ ], int size); or, as you may learn later in the course, similar to this void ascending(int *numbers, int size); Hint: One of the simple sorting algorithms is Bubble Sort. Many websites and videos are available on the Internet. Two of them are: https://www.tutorialspoint.com/data_structures_algorithms/pdf/bubble_sort_algorithm.pdf https://www.tutorialspoint.com/data_structures_algorithms/bubble_sort_program_in_c.htm Modify the main() function of Lab5A.C to call the ascending() function to sort the elements of the array from from smallest to largest. The main function will then print out the 10 sorted elements of the array from smallest to largest. Capture/copy one or two test screen outputs and place it at the end of the C file as multiline comments within /* */. 3. Modify the Lab5B.C program (save it as Lab5C.C) so that it can now do the following: 1) Ask the user to enter 10 random (non-sorted) integer numbers and save them into an array (the same thing as you did in Lab5A.C). 2) Then, print out the 10 sorted elements of the array from from smallest to largest (Lab5B.C). 3) Now, ask the user to enter a search value, do binary search for the number in the 10-element array sorted above. Print out the search value and the element location (i.e. the index) in the array if it has been found, otherwise indicate that the value is not in the array. Hint: One of the simple searching algorithms is Binary Search. You can create a function to do a binary search. Many websites and videos are available on the Internet. Two of them are: https://hackr.io/blog/binary-search-in-c https://www.dailymotion.com/video/x2mxon4 4) Capture/copy two or three test screen outputs and place it at the end of the C file as multiline comments within /* */. 4. Lab5A.C: 2 marks. Lab5B.C: 4 marks. Lab5C.C: 4 mark

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

2 The determinants of international capital flows

Answered: 1 week ago