Write a Program that takes a number and check if the given number is a 3 digit
number or not. (Compulsory to use loops such as for, while)
Answers
The following codes have been written using Python.
Once we receive the input, we assign a variable to represent the number of characters/digits of the number. We start a loop to calculate the same. The travsersing variable 'i', goes through all the characters in 'n', and adds them to the variable representing the number of digits. We use a conditional statement to check if 'c' is equivalent to 3 or not. Appropriate print statements have been given for both cases.
NOTE: Since no actual calculation(s) are being performed, the input has been received in the form of a string value, instead of an integer value. If we were to use , the program would result in an error once the loop starts. In case you'd still like to receive the input in the form of an integer value, appropriate modifications have been made and shown below.