Write the followings as separate three functions that 1. checks if an integer is five-digit and returns the result as an integer value (1 for true, 0 for false) (hint: you can either check the range or find the length of the number) 2. returns the sum of the digits of any given integer (hint: use modulus and division operators) 3. takes an integer as its first parameter, returns the left most and right most digit of that number. (Notice that it returns 2 results at the same time) (hint: use pointers as function parameters, call the function by references) Write a main that uses the above 3 functions to find the sum of the digits and displays the left most and right most digits of given integers. The program stops when a five-digit number is entered.
Write the followings as separate three functions that
1. checks if an integer is five-digit and returns the result as an integer value (1 for true, 0 for
false) (hint: you can either check the range or find the length of the number)
2. returns the sum of the digits of any given integer (hint: use modulus and division operators)
3. takes an integer as its first parameter, returns the left most and right most digit of that
number. (Notice that it returns 2 results at the same time) (hint: use pointers as function parameters,
call the function by references)
Write a main that uses the above 3 functions to find the sum of the digits and displays the left most and
right most digits of given integers. The
Example Run:
Enter a digit number (to stop enter a five-digit number): 456735
Sum of digits = 30
Left most digit is: 4
Right most digit is: 5
Enter a digit number (to stop enter a five-digit number): 142212
Sum of digits = 12
Left most digit is: 1
Right most digit is: 2
Enter a digit number (to stop enter a five-digit number): 961862
Sum of digits = 32
Left most digit is: 9
Right most digit is: 2
Enter a digit number (to stop enter a five-digit number): 12345
Step by step
Solved in 3 steps with 2 images