write a program of 5digit and is reverse:. eg.input:56789. output :98765
Answers
Answered by
3
Question:-
➡ Write a program to input a 5 digit number and display it's reverse.
Program:-
➡ This is written in Java.
import java.util.*;
class Number
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a 5 digit number: ");
int n=sc.nextInt();
int s=0;
while(n!=0)
{
s=s*10+n%10;
n/=10;
}
System.out.println("Reversed number is: "+s);
}
}
Answered by
5
Answer:
import java. util. *;
class Rev
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in) ;
System. out. print on("Enter 5 digit integer") ;
int n=sc.nextInt() ;
int r=0
while (n! =0)
{
r=r*10+(n%10) ;
n/=10;
}
System. out println("Reversed no. is "+r) ;
}
}
Similar questions
History,
4 months ago
Computer Science,
4 months ago
Chemistry,
4 months ago
Math,
9 months ago
Science,
1 year ago