Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please pay attention to the 3rd image that lists the additional requirements! Must be done using C language. CS 159-HW #05 5 Points Possible Due:

image text in transcribedimage text in transcribedimage text in transcribed

Please pay attention to the 3rd image that lists the additional requirements! Must be done using C language.

CS 159-HW #05 5 Points Possible Due: July 19, 2017 at 11:00pm. Problem: Given a positive integer as input, calculate the following and determine if they are multiples: 1. Remove the digit in the ones place of the number and test whether it is a muliple of the original value. Repeat this task until the number reaches zero 2 Sort the digits in the numher from largest to smallest and test whether it is a multiple of the original value 3. Sort the digits in the number from smallest to largcst and test whether it is a multiple of the original valuc. 4. If the number of digits in the input is odd then exchange the digits at the highest and lowest position of the original number und test whether it is a multiple of the original value (example: 38425 becomes 58423) If the number of digits in the input is even then exchange the middle two digits of the original numher and test whether it is a multiple of the original value (example: 1234 becomes 1324) Example Execution #1 : Enter a positive inceger value: 264802 Testing traiue 26490, is not ound to be multiple rest nq v&lue 2648, is not found to be multiple Iesting value26, is not found to be a ultiple Testing value Testing value Testing value 86220, is not found to be a multiplo Testing value 22 468, is not found to be multiple Testing value 268402, is not found to be a multiple. 26, is not found to be a multiple 2, is found to be a mltiple Example Execution #1 Explained: The first five lines of output generated correspond to the repeated removal of digits and comparing the result with the value input. 2. The value 86422t) is the sorted value(largest to smallest, cf the dtgts contaned m the value mpuL 3 The value 22468 is the sorted value (smallest to largest) of the digits contained in the value input. 4. Because the number of digits in the input is even the middle two digits (4 and 8) are exchanged and the new number compared to the input. Example Execution #2: Enter a positive integer value : 135 246 Testing value 135724, is not found to be a multiple Testingvalue 13572, is not found to be a ultiple Testing value 1357, is not found to be a multiple Testing value Testing value Testing value Testinvlue 7654321, is not found to be a multiple Testing value 1234567, is not found * be a multiple resting valu,e 6357241, is not found be multipl 135, is not found to be a mltiple 13, is not found to be a multiple , is found to be a multiple Example Execution #2 Explained: 1 The first six lines of output generated correspond to the repeated removal of digits and comparing the result with the value input. The number of digits in the original input will dictate the number of lines of output that will be generated in this first series of comparisons 2. The value 7654321 is the sorted value (largest to smallest) of the digits contained in the value input 3 The value 1234567 is the sorted value 4 smallest to largest) of the digits contained in the value input 4. Because the number of digits in the input is odd the first and last digits ( and 6) are exchanged and the new number compared to the input. CS 159-HW #05 5 Points Possible Due: July 19, 2017 at 11:00pm. Problem: Given a positive integer as input, calculate the following and determine if they are multiples: 1. Remove the digit in the ones place of the number and test whether it is a muliple of the original value. Repeat this task until the number reaches zero 2 Sort the digits in the numher from largest to smallest and test whether it is a multiple of the original value 3. Sort the digits in the number from smallest to largcst and test whether it is a multiple of the original valuc. 4. If the number of digits in the input is odd then exchange the digits at the highest and lowest position of the original number und test whether it is a multiple of the original value (example: 38425 becomes 58423) If the number of digits in the input is even then exchange the middle two digits of the original numher and test whether it is a multiple of the original value (example: 1234 becomes 1324) Example Execution #1 : Enter a positive inceger value: 264802 Testing traiue 26490, is not ound to be multiple rest nq v&lue 2648, is not found to be multiple Iesting value26, is not found to be a ultiple Testing value Testing value Testing value 86220, is not found to be a multiplo Testing value 22 468, is not found to be multiple Testing value 268402, is not found to be a multiple. 26, is not found to be a multiple 2, is found to be a mltiple Example Execution #1 Explained: The first five lines of output generated correspond to the repeated removal of digits and comparing the result with the value input. 2. The value 86422t) is the sorted value(largest to smallest, cf the dtgts contaned m the value mpuL 3 The value 22468 is the sorted value (smallest to largest) of the digits contained in the value input. 4. Because the number of digits in the input is even the middle two digits (4 and 8) are exchanged and the new number compared to the input. Example Execution #2: Enter a positive integer value : 135 246 Testing value 135724, is not found to be a multiple Testingvalue 13572, is not found to be a ultiple Testing value 1357, is not found to be a multiple Testing value Testing value Testing value Testinvlue 7654321, is not found to be a multiple Testing value 1234567, is not found * be a multiple resting valu,e 6357241, is not found be multipl 135, is not found to be a mltiple 13, is not found to be a multiple , is found to be a multiple Example Execution #2 Explained: 1 The first six lines of output generated correspond to the repeated removal of digits and comparing the result with the value input. The number of digits in the original input will dictate the number of lines of output that will be generated in this first series of comparisons 2. The value 7654321 is the sorted value (largest to smallest) of the digits contained in the value input 3 The value 1234567 is the sorted value 4 smallest to largest) of the digits contained in the value input 4. Because the number of digits in the input is odd the first and last digits ( and 6) are exchanged and the new number compared to the input

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions