Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C programming language Problem: Given a positive integer as input, calculate the following and determine if they are multiples: Remove the digit in the ones

C programming language

Problem: Given a positive integer as input, calculate the following and determine if they are multiples:

Remove the digit in the ones place of the number and test whether it is a multiple of the original value. Repeat this task until the number reaches zero.

Sort the digits in the number from largest to smallest and test whether it is a multiple of the original value.

Sort the digits in the number from smallest to largest and test whether it is a multiple of the original value.

If the number of digits in the input is odd then exchange the digits at the highest and lowest position of the original number and 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 number and test whether it is a multiple of the original value (example: 1234 becomes 1324).

************** Output has to to be exact to sample executions ********************

Example Execution #1: Enter a positive integer value: 264802

Testing value 26480, is not found to be a multiple. Testing value 2648, is not found to be a multiple. Testing value 264, is not found to be a multiple. Testing value 26, is not found to be a multiple. Testing value 2, is found to be a multiple. 
Testing value 864220, is not found to be a multiple. Testing value 22468, is not found to be a multiple. Testing value 268402, is not found to be a multiple. 

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.

The value 864220 is the sorted value (largest to smallest) of the digits contained in the value input.

The value 22468 is the sorted value (smallest to largest) of the digits contained in the value input.

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 #3 (input validation requirement demonstrated):

Enter a positive integer value: 0 Error! Positive values only! Enter a positive integer value: 123000 
Testing value 12300, is found to be a multiple. 
Testing value 12300, is found to be a multiple. Testing value 1230, is found to be a multiple. Testing value 123, is found to be a multiple. Testing value 12, is found to be a multiple. Testing value 1, is found to be a multiple. Testing value 321000, is not found to be a multiple. Testing value 123, is found to be a multiple. Testing value 120300, is not found to be a multiple. 

Each example execution represents a single test of your program.

Use of loops allowed, The use of arrays are not permitted on this assignment.

With our ability to implement user-defined functions only the following will be permitted in the main function:

Declaration of variables to be passed to functions.

Calls to user-defined functions by main.

A limited amount of control structures (see chapters 5 and 6) to retain the previous two tasks within the main

function.

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions