Computer Science, asked by mdzakeeanwar8, 6 months ago

16.
}
Write a program to read a single digit integer (>1) say n and then return a 3 digit integer as per
(n-1) n (n+1). That is, if you enter 5, then it should print : 456

Answers

Answered by anindyaadhikari13
2

Question:-

Write a program to read a single digit integer(>1) say n and then return a three digit integer as per (n-1)n(n+1).

Code:-

Here is your code.

In Java.

class x

{

static void main(int n)

{

if(n>1&&n<=9)

System.out.println((n-1)+""+n+""+(n+1));

else

System.out.println("Invalid Number. Please try again. ");

}

}

In Python.

n=int(input("Enter a digit: "))

if n>1 and n<10:

print((n-1),"",n, ""(,n+1))

else

print("Invalid. Please try again. ")

Similar questions