Computer Science, asked by vaibhavchauhan791, 10 months ago

write a program that inputs an integer in range 0 to 999 and then prints if the integer entered is a 1 / 2 / 3 digit number​

Answers

Answered by Maxcaulfield
21

Do I have to use Python3?

If yes, here is the code:

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

if len(a)=1:

print(a)

elif len(a)=2:

print(a)

elif len(a)=3:

print(a)

You could put a else statement after this if you don't want an error:

else:

print("Not a 1, 2 or 3 digit number")

Please mark as brainliest!

Answered by akshayamca14
2

Answer:

public static void Main()

{

 

 string number=Console.ReadLine();

 if(number.Length==3)

 {

  Console.WriteLine("3 digit number");

 }else if(number.Length==2){

  Console.WriteLine("2 digit number");

 }else if(number.Length==1){

  Console.WriteLine("1 digit number");

 }else{

  Console.WriteLine("more than 3 digit number");

 }

}

Explanation:

Similar questions