Computer Science, asked by anish4416, 8 months ago


2. Write a program that inputs an integer in range 0-999 and then prints if the integer
entered is a 1/2/3 digit number. Use nested if statements.​

Answers

Answered by siddharth3690
6

Answer:

Following is the implementation for the same. The code supports numbers up-to 4 digits, i.e., numbers from 0 to 9999. Idea is to create arrays that store individual parts of output strings. One array is used for single digits, one for numbers from 10 to 19, one for 20, 30, 40, 50, .. etc, and one for powers of 10. 

The given number is divided in two parts: first two digits and last two digits, and the two parts are printed separately.

 

Answered by reneshL
1

Answer:

num=int(input("Enter a number : "))

if num<0:

   print("Invalid entry")

elif num<10:

   print("single digit number")

elif num<100:

   print("double digit number")

elif num<1000:

   print("Three digit number")

else:

   print("not vailed number, The number should lie between 0 to 999 only")

   

Explanation:

Similar questions