Problem: Given 20 positive integers as input, calculate the number of divisors for each integer and sort the data set from smallest to largest based on the number of divisors. When multiple integers have the same number of divisors then sort them smallest to largest. Examples: Integer value 12 has divisors 1, 2, 3, 4, 6, 12 for a total of 6. Prime numbers only have divisors of 1 and the number itself. The integer 1, the smallest value that will be provided as input, has only a single divisor, itself. Example Execution #1: Enter 20 integer values -> 21 15 10 6 3 1 28 13 5 7 9 29 31 37 17 19 12 43 24 2 Data sorted by number of divisors: 1 2 3 5 7 13 17 19 29 31 37 43 9 6 10 15 21 12 28 24 Example Execution #2 (data does not have to be unique): Enter 20 integer values -> 9 7 5 3 8 6 4 2 9 7 5 3 8 6 4 2 9 7 5 3 Data sorted by number of divisors: 2 2 3 3 3 5 5 57 7 7 4 4 9 9 9 6 6 8 8

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 16SA
icon
Related questions
Question
Problem: Given 20 positive integers as input, calculate the number of divisors for each integer and sort the data set from
smallest to largest based on the number of divisors. When multiple integers have the same number of divisors then sort
them smallest to largest.
Examples: Integer value 12 has divisors 1, 2, 3, 4, 6, 12 for a total of 6. Prime numbers only have divisors of 1 and the
number itself. The integer 1, the smallest value that will be provided as input, has only a single divisor, itself.
Example Execution #1:
Enter 20 integer values -> 21 15 10 6 3 1 28 13 5 7 9 29 31 37 17 19 12 43 24 2
Data sorted by number of divisors: 1 2 3 5 7 13 17 19 29 31 37 43 9 6 10 15 21 12 28 24
Example Execution #2 (data does not have to be unique):
Enter 20 integer values -> 9 7 5 3 8 6 4 2 9 75 3 8 6 4 2 9 7 5 3
Data sorted by number of divisors: 2 2 3 33 5 5 5 7 7 7 4 4 9 9 9 6 6 8 8
Transcribed Image Text:Problem: Given 20 positive integers as input, calculate the number of divisors for each integer and sort the data set from smallest to largest based on the number of divisors. When multiple integers have the same number of divisors then sort them smallest to largest. Examples: Integer value 12 has divisors 1, 2, 3, 4, 6, 12 for a total of 6. Prime numbers only have divisors of 1 and the number itself. The integer 1, the smallest value that will be provided as input, has only a single divisor, itself. Example Execution #1: Enter 20 integer values -> 21 15 10 6 3 1 28 13 5 7 9 29 31 37 17 19 12 43 24 2 Data sorted by number of divisors: 1 2 3 5 7 13 17 19 29 31 37 43 9 6 10 15 21 12 28 24 Example Execution #2 (data does not have to be unique): Enter 20 integer values -> 9 7 5 3 8 6 4 2 9 75 3 8 6 4 2 9 7 5 3 Data sorted by number of divisors: 2 2 3 33 5 5 5 7 7 7 4 4 9 9 9 6 6 8 8
Additional Requirements:
1. Add the homework assignment header file to the top of your program. A description of your program will need to
be included in the assignment header. This particular header can be added to your file by entering hhw while in
command mode in vi.
2. Each of the example executions provided for your reference represents a single execution of the program.
Your program must accept input and produce output exactly as demonstrated in the example executions. Your
program will be tested with the data seen in the example executions and an unknown number of additional tests
making use of reasonable data.
All data input will be of the int data type and non-negative. There is no input validation requirement.
3. For this assignment you will be required to implement the user-defined functions (from chapter 4). Failing to
follow course standards as they relate to good user-defined function use will result in a zero for this assignment.
4. Revisit course standards as it relates what makes for good use of user-defined functions, what is acceptable
to retain in the main function, and when passing parameters by address is appropriate.
In many cases user-defined function use should result in a main function that only declares variables and
makes function calls.
5. Course standards prohibit the use of programming concepts not yet introduced in lecture. For this assignment
you can consider all material in the first eight chapters of the book, notes, and lectures to be acceptable for use.
The use of any dynamic array structures (chapters 9 and 10) would violate this requirement and result in no
credit being awarded for your effort. See course standards that follow for array declaration expectations.
6. A program MUST compile to be considered for partial credit. The submission script will reject the submission of
any file that does not successfully compile on the guru server. The name of the source code file you attempt to
submit must be hw06.c, no variation is permitted.
Transcribed Image Text:Additional Requirements: 1. Add the homework assignment header file to the top of your program. A description of your program will need to be included in the assignment header. This particular header can be added to your file by entering hhw while in command mode in vi. 2. Each of the example executions provided for your reference represents a single execution of the program. Your program must accept input and produce output exactly as demonstrated in the example executions. Your program will be tested with the data seen in the example executions and an unknown number of additional tests making use of reasonable data. All data input will be of the int data type and non-negative. There is no input validation requirement. 3. For this assignment you will be required to implement the user-defined functions (from chapter 4). Failing to follow course standards as they relate to good user-defined function use will result in a zero for this assignment. 4. Revisit course standards as it relates what makes for good use of user-defined functions, what is acceptable to retain in the main function, and when passing parameters by address is appropriate. In many cases user-defined function use should result in a main function that only declares variables and makes function calls. 5. Course standards prohibit the use of programming concepts not yet introduced in lecture. For this assignment you can consider all material in the first eight chapters of the book, notes, and lectures to be acceptable for use. The use of any dynamic array structures (chapters 9 and 10) would violate this requirement and result in no credit being awarded for your effort. See course standards that follow for array declaration expectations. 6. A program MUST compile to be considered for partial credit. The submission script will reject the submission of any file that does not successfully compile on the guru server. The name of the source code file you attempt to submit must be hw06.c, no variation is permitted.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning