Answer:
The program in Python is as follows:
num = int(input("4 digit number: "))
numstr = str(num)
if(len(numstr)!=4):
print("Number must be 4 digits")
else:
numstr = numstr[::-1]
num = int(numstr)
print(num)
Step-by-step explanation:
This prompts user for input
num = int(input("4 digit number: "))
This converts the input number to string
numstr = str(num)
This checks if number of digits is or not 4
if(len(numstr)!=4):
If not, the following message is printed
print("Number must be 4 digits")
else:
If digits is 4,
This reverses the string
numstr = numstr[::-1]
This converts the reversed string to integer
num = int(numstr)
This prints the reversed number
print(num)