Write a program to input a three digit number and display all the
digits by using arithmetical operators.
Sample Input: 472
Sample Output: 4
7
2
comments of the program
Answers
Answered by
3
The following codes have been written using Python.
We input the data using the input() function, and call it with the int() function to ensure that the data being input is an integer value. To check if it's a 3-digit number or not, we use a conditional statement. If it results to True, it proceeds with the rest of the program, printing each digit line by line.
Another shorter approach is as follows:
This code, however, prints the digits from the unit's place first, onto the hundredth's place.
Similar questions