reverse a number in java by bufferedreader
Answers
Answered by
1
import java.io.*;
public class Reverse number
{
public static void main (String args[])throws IOException
{
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
int n, reverse=0;
System.out.println("Enter a number to reverse");
n=Integer.parseInt(in.readLine());
while(n != 0)
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
}
System.out.println("Reverse of the number is " + reverse);
}
}
Hope this coding using buffered reader helps you a lot !!!
public class Reverse number
{
public static void main (String args[])throws IOException
{
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
int n, reverse=0;
System.out.println("Enter a number to reverse");
n=Integer.parseInt(in.readLine());
while(n != 0)
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
}
System.out.println("Reverse of the number is " + reverse);
}
}
Hope this coding using buffered reader helps you a lot !!!
sonai15:
yea
Similar questions