Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 12 Weeks Ago, 3 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
C PROGRAMMING
Write a program (sort.c) that asks the user to enter a number of integers, stores them in an array, andthe sorts the array in decreasing order. Your program should do the following:
- Ask the user to enter an integer between 2 and 15. This will represent the number of elementsto in the array
- Check if the input is between 2 and 15. If not, your program should keep asking the user to enteran integer between 2 and 15 until a valid input is entered.
- Ask the user to enter the specified number of integers.
- Read those integers into an array
- Print the array before sorting
- Sort the array in decreasing order: (assume that the last index of the array is LAST)
o Find the largest element of the array (use the function written in part II)
o Swap the largest element with the element at position 0
o Find the largest element between position 1 and LAST
o Swap the largest element with the element at position 1
o Find the largest element between position 2 and LAST
o Swap the largest element with the element at position 2
o Repeat until all elements are sorted
- Print the array after sorting Compile your program, call the executable sort.Submit through the handin system the source code sort.c and the executable sort
-----------