Question: Problem: 4 - digit number In this problem, you will have to implement the following functions. After implementing the functions, you have to call those

Problem: 4-digit number
In this problem, you will have to implement the following functions. After implementing the functions, you have to call
those functions properly from the main function or other functions appropriate to get the correct output. Please read
the function descriptions carefully to identify the return type and parameters of the functions.
The main objective of the code is to take a four-digit integer as input and then perform some required operations on it.
Function 1:
Name: isFourDigit()
Precondition: the function takes an integer as a parameter (you can assume it is a positive integer)
Post condition: The function returns 1 if the number is 4 digits number. Otherwise, the function will return 0.
Function 2:
Name: reverse4Digit()
Precondition: the function takes a 4 digits positive integer as part of the parameter
Post condition: The function reverse the 4-digit number and returns it. Before reversing the number, it calls
the isFourDigit() function to check whether the number is 4 digits or not to prevent potential error during the
calculation. If the function cannot reverse the number as the number of digits is not 4 digits, it returns -1.
Function 3:
Name: addSides4Digit()
Precondition: the function takes a 4 digits positive integer as part of the parameter
Post condition: The function adds the first and last digit of the number and prints their sum. Before extracting the first
and last digits, it calls the isFourDigit() function to check whether the number is 4 digits or not to prevent potential
error during calculation (if you do not use a loop). If the function sees that the number of digits is not 4, it prints "Invalid
input to calculate sides". Note that the function does not return anything. NO WHILE LOOPS PLEASE
Problem: 4 - digit number In this problem, you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!